0

最後のアイテム名、画像、URL、および価格を取得する必要があります。

$session= Mage::getSingleton('checkout/session');
foreach($session->getQuote()->getAllItems() as $item)
{
$productid = $item->getProductId();
$productname = $item->getName();
$productqty = $item->getQty();
}

これは機能していますが、画像と URL を取得できません。

4

1 に答える 1

2

コレクションは通常、オブジェクト全体をロードしません。必要な他のデータを取得するには、オブジェクトを再ロードする必要があります。

$session= Mage::getSingleton('checkout/session');
// Get all items, including child / hidden items
foreach($session->getQuote()->getAllItems() as $item) {
    $_prod = Mage::getModel('catalog/product')->load($item->getProductId());
    $productname = $_prod->getName();
    $productqty = $_prod->getQty();
    // Now you have a full loaded Product Object.
}
// Visible items only
foreach($session->getQuote()->getAllVisibleItems() as $item) {
    $_prod = Mage::getModel('catalog/product')->load($item->getProductId());
    $productname = $_prod->getName();
    $productqty = $_prod->getQty();
    // Now you have a full loaded Product Object.
}
于 2013-02-26T13:58:38.493 に答える