product has a custom options or not in magento?

2019-09-07 12:51发布

问题:

how to check that product has a custom options or not in magento?

Mage::setIsDeveloperMode(true);         
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$product    = Mage::getModel('catalog/product')->load($sku, 'sku');
$code = $product->getAttribute()->getAttributeCode();

回答1:

$product    = Mage::getModel('catalog/product')->load($sku, 'sku');
$hasOptions = $product->hasCustomOptions();

Simple as that. At the end $hasOptions should be true or false.



标签: magento