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.

3 Answers 3

4

Get product id in minicart

$_item = $this->getItem();
$productId = $_item->getProduct()->getId(); 
1
  • You know you can mark it accepted ;) Oct 13, 2017 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>";           
    
        ?>
    
1
  • thank you, look like I will need it when I want get others data
    – mrfizh
    Oct 13, 2017 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();
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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