Magento 可配置产品属性
嘿伙计们,我在使用 magento 时遇到了一个问题,我似乎无法找到解决方案。
我已经尝试了很多方法来获取可配置的产品属性(简单的产品)并列出它们,现在我有两种方式列出它们,但我使用的方式低于
$confAttributes = @$_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
$sizes = array();
foreach($confAttributes AS $atts){
//print '';//'<pre style="display:none;">'.print_r($atts).'</pre>';
if($atts['label'] == 'Size'){
foreach($atts['values'] AS $val){
$sizes[] = $val['store_label'];
}
}
}
我现在唯一的问题是我只需要拉回尺寸库存属性 - 查看法师文件以找到解决方案,但看不到任何内容 - 我需要的结果是在配置产品 php 文件中完成的,但我无法从需要列出尺寸属性的代码中访问它。
任何帮助都会很棒,谢谢!
hey guys, having an issue with magento which i just cant seem to find a solution to.
i have tried many ways of getting a configurable products attributes (simple products) and listing them, now i have them listing from 2 ways but the way im working with is below
$confAttributes = @$_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
$sizes = array(); foreach($confAttributes AS $atts){ //print '';//'<pre style="display:none;">'.print_r($atts).'</pre>'; if($atts['label'] == 'Size'){ foreach($atts['values'] AS $val){ $sizes[] = $val['store_label']; } } }
my only problem with this now is i need to only pull back the size attributes which are in stock - looked through mage files to find solution but just cant see anything - the result i need is done in config product php file but i cant access it from in the code where i need to list the size attribute.
any help would be great, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决方案:
您可以使用以下代码轻松获取任何其他 PHTML 文件上的所有可配置(产品)详细信息页面信息:
例如:就我而言,我正在获取catalog/product/list.phtml 的详细信息。
谢谢,
Solution:
You can get easily all configurable(product) details page information on any other PHTML file by using following code:
e.g.: in my case i'm getting details on catalog/product/list.phtml.
Thanks,
找到了解决方案,我必须使用上面我已经编码的内容,并使用相关产品的尺寸,然后检查库存水平并将它们放入数组中,并在构建我的属性列表时检查库存 - 效果很好 - 其他人都有更好的解决方案请分享:D谢谢
found the solution, i had to use the above what i had already coded and use assosicated products for the size and then check the stock levels and put them into an array and check the stock when building my attribute list - works great - anyone else have a better solution please share :D thanks