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:


foreach($this->getItems() as $_item){
    $currentItemVendorId = Mage::getModel('catalog/product')->load($_item->getProduct()->getId())->getData('vendor');

The issue at hand is that $this->getItems() returns only visible items ( see Mage_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:

foreach($this->getQuote()->getAllItems() as $_item){

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:

foreach($this->getQuote()->getAllItems() as $_item){
   if($_item->getProduct()->getTypeId()=='simple' && $_item->getParentId()){
      //then it's a simple child!

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.