$product = Mage::getModel('catalog/product')->load(3);
$childProducts = Mage::getModel('catalog/product_type_configurable')
->getUsedProducts(null,$product);
foreach($childProducts as $child) {
print_r($child->getName()); // You can use any of the magic get functions on this object to get the value
}
/**
* Load product by product id
*/
$product = Mage::getModel('catalog/product')->load(YOUR_PRODUCT_ID);
/**
* Get child products id and such (only ids)
*/
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
/**
* Get children products (all associated children products data)
*/
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
5 回答
使用以下脚本
在脚本内:
现在将
onchange
事件添加到同一页面的下拉列表中:Full description
使用以下代码
用于获取完整产品信息的代码(其中3是可配置产品ID)
获得儿童产品ID的另一个代码
希望这可以帮助!!
可配置产品可以包含多个与之关联的其他产品 .
以下是获取与可配置产品关联的所有子产品的代码 .
这里是代码:)
资料来源:http://blog.chapagain.com.np/magento-how-to-get-all-associated-children-product-of-a-configurable-product/
我知道了 . 谢谢你的回复 .
对于任何想要这样做的人,并显示结果,我将分享我所做的一切,以完成它
添加到
script
段: app/design/frontend/default/[your_theme]/template/catalog/product/view/type/options/configurable.phtml在同一页面的
select
中添加:随意编辑语句打印的内容,但这应该可以帮助您 . 它还占有0库存,在css和文本中将其更改为
Out of stock