簡體   English   中英

Magento可配置產品屬性

[英]Magento Configurable Product Attributes

大家好,我似乎無法找到解決方案。

我嘗試了多種方法來獲取可配置的產品屬性(簡單產品)並列出它們,現在我從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文件中完成,但我無法訪問它從我需要列出size屬性的代碼中。

任何幫助將是巨大的,謝謝!

解決方案:通過使用以下代碼,您可以輕松獲取任何其他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;?>      

謝謝,

找到解決方案后,我必須使用上面我已經編碼的方法,並使用相關產品作為尺寸,然后檢查庫存水平並將它們放入數組中,並在建立我的屬性列表時檢查庫存-很好-任何其他人都有更好的解決方案,請分享:D謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM