2011-02-11 189 views
1

嘿家伙,与magento的问题,我只是不能找到解决方案。Magento可配置产品属性

我试图得到一个可配置的产品属性(简单的产品),并列出它们的方法很多,现在我让他们从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']; } } }

我唯一的问题现在这是我需要只拉回有库存的大小属性 - 通过法师文件查找找到解决方案,但只是无法看到任何东西 - 我需要的结果是在配置产品的PHP文件中完成,但我不能访问它在代码,我需要列出大小属性。

任何帮助将是伟大的,谢谢!

+0

所以你需要有大小属性​​和有库存的产品? – 2011-02-11 11:38:10

+0

嗨安东,当我进入一个可配置的产品时,我需要得到它的各种尺寸,正确的顺序,并且只有在库存中,我设法得到这个后挖掘了很多。 :D现在全部排序! yay – coder4show 2011-02-11 14:41:13

回答

0

找到了解决方案,我不得不使用上面我已经编码的内容,并使用assosicated产品的大小,然后检查库存水平并将它们放入数组中,并在构建属性列表时检查库存 - 工作良好 - 其他人有更好的解决方案,请分享:d感谢

+0

只需将尺寸和库存属性添加到产品集合中作为过滤器,并且您无需通过“蛇笔*”即可访问它们。:) – 2011-02-11 14:25:46

1

解决方案: 你可以很容易地在任何其他PHTML文件中的所有配置的(产品)的详细信息页面信息通过使用下面的代码: 例如:在我的情况下,我获取目录/产品/ 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;?>  

感谢,

相关问题