2011-02-11 186 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;?>  

感謝,

相關問題