2

How to get product id from product which already added to cart in mini cart ?

I've opened this file :

app/design/frontend/<theme_name>/default/template/checkout/cart/minicart/default.phtml

but I still not have idea to get product id.

4

Get product id in minicart

$_item = $this->getItem();
$productId = $_item->getProduct()->getId(); 
  • You know you can mark it accepted ;) – Dinesh Yadav Oct 13 '17 at 10:37
2
  1. You can get all product data with $product variable.

    <?php $_item = $this->getItem() ?>
    
       <?php 
    
            $product = Mage::getModel('catalog/product')
            ->load($_item->getProductId()); 
    
           echo "<pre>";
           print_r($product->getData());
           echo "</pre>";           
    
        ?>
    
  • thank you, look like I will need it when I want get others data – mrfizh Oct 13 '17 at 10:37
1

You can get product data with $product variable using below code.

$_item = $this->getItem();
$product = $_item->getProduct(); 

And you can get product id using $product variable like below.

$productId = $product->getId();

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.