1

I want to show attachment link with every product which is in cart. I only need product id on cart.phtml, but product are rendering with this code

   <?php foreach($this->getItems() as $_item): ?>
       <?php echo $this->getItemHtml($_item) ?>                                      
    <?php endforeach ?>`

and I am unable to fetch product Id, how can I get product Id so that I can show link with every product in cart.

I am working with configurable product and $productID = $_item->getProductId(); returns always parent id. Is any way to get child product id in cart ?

3

When you turn on hints in System>Config>Developer (on the bottom of the left list), you'll see that each line item in the cart is a reference to an instance of cart/item/default.phtml. (this is what getItemHtml() is generating on this pYou'll also see, at the top of this file, a line of code along the lines of:

$_item = $this->getItem();

$_item is of type Mage_Sales_Model_Quote_Item, so we can access quote variables from it, for instance:

$productID = $_item->getProductId();
  • Many thanks for answer, but I am working with configurable product and $productID = $_item->getProductId(); returns always parent id. Is any way to get child product id in cart ? – paicubes May 5 '14 at 14:29

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.