Francis Kim
Francis Kim

Reputation: 4285

Magento - How to get attributes of a child product of a bundled item

I need to retrieve a simple text attribute from a child product belonging to a bundled product if it exists. This needs to be done on the shopping cart page. The below is the code I've been messing around with to see what I can retrieve.

The file is template/checkout/cart/item/default.phtml in the theme folder.

$_item = $this->getItem();
$_product = $this->getProduct();
$_product = Mage::getModel('catalog/product')->load($_product->getId());
$isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();

    $itemsCollection = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
    foreach($itemsCollection as $item) {
        echo $item->getId();
        $_bProduct = Mage::getModel('catalog/product')->load($item->getId());
        echo '<pre>';
        var_dump($_bProduct);
        echo '</pre>';
        echo '<br>';
        echo $_bProduct->getData('backorder_shipment_date');

    }

Upvotes: 0

Views: 2785

Answers (1)

Oğuz &#199;elikdemir
Oğuz &#199;elikdemir

Reputation: 4980

To access custom attributes on all pages, you should use :

getItemCollection()
or
getProductCollection()

also, check this link Accessing Custom Product Attributes in the Cart/Checkout Area

Upvotes: 1

Related Questions