1. 获取全部
//get Product
$cProduct = Mage::getModel('catalog/product')->load($_product->getId());
//check if product is a configurable type or not
if ($cProduct->getData('type_id') == "configurable")
{
//get the configurable data from the product
$config = $cProduct->getTypeInstance(true);
//loop through the attributes
foreach($config->getConfigurableAttributesAsArray($cProduct) as $attributes)
{
echo $attributes["label"];
foreach($attributes["values"] as $values)
{
echo $values["label"];
}
// do stuff....
}
}
NOTE: This does not get all the values possible, it only gets what you have in stock.
ie. For my configurable product, I have the options of Colors:
R,B,G,Y,W,B and Sizes: S, M, L, but I only had stock for Colors R,B,G
and Sizes S and L.
来源:http://www.magentocommerce.com/boards/v/viewthread/69838/#t199215
2. 获取单项(size为例)
When dealing with configurable products (or any time you're dealing with
a concept for only one type of product, as configurable attributes
are), you'll probably be working with getTypeInstance
. See
below, I grab the configurable attributes for the product, then find the
one for size. You could also just run through every configurable
attribute if you wanted. Or if size is the only configurable attribute,
just skip that if()
.
$attrs = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
foreach($attrs as $attr) {
if(0 == strcmp("size", $attr['attribute_code'])) {
$options = $attr['values'];
foreach($options as $option) {
print "{$option['store_label']}<br />";
}
}
}
来源: http://stackoverflow.com/questions/2742707/magento-and-configurable-product-attributes
更多参考: magento 获取产品存货量以及configurable product 下associated children product信息
分享到:
相关推荐
我们公司在用的商城产品属性过滤插件,希望对大家有用,同时,看还有什么好的建议和意见也可以提出,我们再次修改
magento颜色属性图片展示插件,经过测试适用于magento1.7
此插件功能可以在后台添加magento的客户属性已经客户地址属性,已在1.8.1测试,正常安装使用。
Magento 2 is installable only via the command-line interface for an experienced webmaster. Chapter 2, Magento 2 System Tools, explains how to install Magento 2 via the command shell. Magento released ...
magento 颜色属性切换图片,兼容1.4-1.9,有说明文档,和安装截图
magento通过mysql语句批量导出产品及其自定义属性
attributes is an important step in setting up a Magento store. Chapter 5, Managing Your Store, covers setting up the correct tax rules, configuring an inventory, and creating customer groups. Chapter ...
He is an active member of the community and has been recognized as a Magento Master for 2017. He is the Chief Operating Officer of Wagento, a full-service Magento Solution Partner with offices in ...
将自定义属性添加到Magento类别 用于将自定义属性添加到Magento类别的模块。 我已经设置了位于app / code / local / Samuidavid / CustCatAttr / sql / custcatattr_setup中的安装脚本,以将新的图像输入字段添加到...
Magento 2客户属性扩展示例此扩展程序展示了如何使用Magento 2扩展程序创建客户属性。
magento 批量上传产品,多图,自定义属性
magento数据结构分析 magento数据字典
magento通过产品名称获取产品id提示代码
magik shoes magento 模板, magento 1.7 模板
magento的SMTP插件magento的SMTP插件magento的SMTP插件
这个文件用于magento 批量上传产品后,前端只显示产品主图不能显示详细图片的bug. 也可用于批量上传商品的尺码或属性。注意: media_img.csv和 attrib.csv这两个文件只能放在tool目录里面。这个工具测试了magento ...
Get a detailed insight into the structure of Magento Learn about event/observer-driven modules Get a hands-on introduction to custom shipping and payment methods ☆ 出版信息:☆ [作者信息] Branko ...
深入理解Magento 由精东博客下载下来制作成pdf
New GUI added 10 predefined block positions on each page Ability to place any block in any position by easily ... Meets Magento programming practices for most versions and customizations compatibility