magento: configurable 显示所有属性及获取 Json Config how to get Json Config by product id

1. 显示所有属性

$config_product = Mage::getModel('catalog/product')->load($_product->getId());
$productAttributeOptions = $config_product->getTypeInstance(true)->getConfigurableAttributesAsArray($config_product);

 

源于:http://stackoverflow.com/a/17045189/602382

 

2. 获取 Json Config

$mageFilename = 'app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();//instantiate the application
$block = Mage::app()->getLayout()->createBlock('catalog/product_view_type_configurable');
$block->setProduct($_product);
$json_config  =  $block->getJsonConfig();

 

源于:http://www.magentocommerce.com/boards/v/viewthread/647045/#t462553

你可能感兴趣的:(config)