1

I am working with configurable product, I want simple product id of configurable product on cart.phtml, I am using this code

 <?php foreach($this->getItems() as $_item): ?>
$_product = $_item->getProduct();
echo $_product->getId();
 <?php endforeach ?>

but it always gives main product id, but I need its simple product id , any one help please.

paicubes
  • 151
  • 1
  • 7
  • try this link http://stackoverflow.com/questions/12286716/get-all-simple-product-from-a-configurable-product-in-magento-product-view – Sayali May 08 '14 at 09:27

2 Answers2

0

I found solution

<?php foreach($this->getItems() as $_item): ?>
  $_COnfigproduct = $_item->getProduct();
$simpleProduct=Mage::getModel('catalog/product')->loadByAttribute('sku',$_item->getSku());
echo $simpleProduct->getId();
<?php endforeach ?>

it works for me.

paicubes
  • 151
  • 1
  • 7
0

you can get simple product id associated to configurable product on cart page.. by below code

<?php $_item = $block->getItem();
$product = $_item->getProduct();
if($product->getTypeId() == 'configurable') {
echo $_item->getOptionByCode('simple_product')->getProduct()->getId();
} ?>
Dixita
  • 54
  • 3