I am creating magento store. I am beginner in magento. I want to get product id and product input type in my phtml file is this possible? please guide me..
I am trying to this way to get product type. but its not working for me
$product=Mage::getModel('catalog/product')->load($product_id);
$productType=$product->getTypeID();
Please guide me...
To get the product type you will use get_type() method. To check the product type inside an IF statement you will use is_type() method.
By default, Magento 2 supports 6 product types. These are: Simple, Groped, Configurable, Virtual, Bundle and Downloadable products.
Try below code to get currently loaded product id:
$product_id = $this->getProduct()->getId();
When you don’t have access to $this, you can use Magento registry:
$product_id = Mage::registry('current_product')->getId();
Also for product type i think
$product = Mage::getModel('catalog/product')->load($product_id);
$productType = $product->getTypeId();
<?php if( $_product->getTypeId() == 'simple' ): ?>
//your code for simple products only
<?php endif; ?>
<?php if( $_product->getTypeId() == 'grouped' ): ?>
//your code for grouped products only
<?php endif; ?>
So on. It works! Magento 1.6.1, place in the view.phtml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With