[英]Magento Configurable Product Attributes
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 我尝试了多种方法来获取可配置的产品属性(简单产品)并列出它们,现在我从2种方法中列出它们,但我使用的方法如下
$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. 我现在唯一的问题是我只需要拉回库存中的大小属性-通过法师文件查找解决方案,但看不到任何东西-我需要的结果在配置产品php文件中完成,但我无法访问它从我需要列出size属性的代码中。
any help would be great, thanks! 任何帮助将是巨大的,谢谢!
Solution: You can get easily all configurable(product) details page information on any other PHTML file by using following code: eg: in my case i'm getting details on catalog/product/list.phtml. 解决方案:通过使用以下代码,您可以轻松获取任何其他PHTML文件上的所有可配置(产品)详细信息页面信息:例如:在我的情况下,我正在获得catalog / product / list.phtml的详细信息。
<script src="<?php echo Mage::getBaseUrl('js') ?>varien/configurable.js" type="text/javascript"></script>
<?php
$temp = new Mage_Catalog_Block_Product_View_Type_Configurable();
$temp->setData('product', $_product);
$_attributes = Mage::helper('core')->decorateArray($temp->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<?php foreach($_attributes as $_attribute): ?>
<?php
$prices = $_attribute->getPrices();
foreach($prices as $price) {
echo $price['pricing_value'] . "<br/>";
}
?>
<?php endforeach; ?>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $temp->getJsonConfig() ?>);
</script>
<?php endif;?>
Thanks, 谢谢,
找到解决方案后,我必须使用上面我已经编码的方法,并使用相关产品作为尺寸,然后检查库存水平并将它们放入数组中,并在建立我的属性列表时检查库存-很好-任何其他人都有更好的解决方案,请分享:D谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.