I'm editing the order in which the cart items appear in the table. I am trying to get the "vendor" super attribute value from each $this->getItems() as $_item. $_item->getProduct()->getId() is returning the simple product's parent configurable product id. I need to obtain values from the simple product in the cart. I'm not sure why $_item->getProduct()->getId() is giving me the parent Id. How do I get the "vendor" value. I have tried the following among other similar methods:
/template/checkout/cart.phtml
foreach($this->getItems() as $_item){
$currentItemVendorId = Mage::getModel('catalog/product')->load($_item->getProduct()->getId())->getData('vendor');
}
Best Answer
The issue at hand is that
$this->getItems()
returns only visible items ( seeMage_Checkout_Block_Cart_Abstract::getItems()
. Visible items include the configurable parent but not the children.In that case you will need to do something akin to:
This will return all of the items including both the parent configurable and the child. To filter just for the simple child you'd do something like:
As an aside, in the future, you needn't call
load
again on Product ID as you already have the product with$_item->getProduct()
. If product information isn't loading in a particular scope try adding it to the collection.