2015-02-10 32 views
1

我正在使用Magento 1.9.1.0,並且具有可配置的色板,可用於類別和產品查看頁面。我試圖在自定義類別頁面上顯示可配置的色板(magento 1.9)

我試圖創建一個列出所有產品(商店只有+/- 20)的定製'商店'頁面,顯示產品下面的可配置色板。

我可以創建Shop頁面,其中列出了所有產品的許多方法..無論是通過CMS,local.xml,或使用控制器等...沒有問題。

這是local.xml的例子。 *我有適當的路線設置,並且默認類別設置爲「是錨點」。

<mystore_site_index_shop> 
    <reference name="content"> 
      <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml"> 
       <block type="core/text_list" name="product_list.name.after" as="name.after" /> 
       <block type="core/text_list" name="product_list.after" as="after" /> 
       <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml"> 
        <block type="page/html_pager" name="product_list_toolbar_pager"/> 
       </block> 
      </block> 
    </reference> 
</mystore_site_index_shop> 

我還添加了頁面引用的頁面中configurableswatches.xml

<mystore_site_index_shop> 
    <update handle="product_list"/> 
</mystore_site_index_shop> 

其加載相應的.js文件的頁面......然而,沒有樣本顯示。

有沒有人有任何建議,我怎麼能做到這一點?我必須在這裏丟失一些明顯的東西..

謝謝!

回答

1

嘗試在mystore_site_index_shop塊之後的local.xml文件內添加產品列表更新。

內部本地。XML

<mystore_site_index_shop> 
    <update handle="product_list"/> 
</mystore_site_index_shop> 

- 編輯 -

即使我能得到這個使用我上面貼的方法工作。根據我的理解,正確的方法是將您的整個主題構建爲rwd主題的子項,使您可以在不使用任何黑客的情況下使用色板。

應用程序/設計/前端內/ YOURTHEME /缺省的/ etc/theme.xml

<?xml version="1.0"?> 
<theme> 
<parent>rwd/default</parent> 
</theme> 
+0

在'..index_shop'塊之後添加'product_list'塊,取得了訣竅!我實際上直接使用RWD主題 - 奇怪?謝謝! – user2682676 2015-02-16 18:16:35

1

如果你去到應用程序/代碼/核心/法師/ ConfigurableSwatches的/ etc/config.xml中 你會看到觀察者對catalog_block_product_list_collection活動上線83

<catalog_block_product_list_collection> 
 
       <observers> 
 
        <configurableswatches> 
 
         <class>configurableswatches/observer</class> 
 
         <method>productListCollectionLoadAfter</method> 
 
        </configurableswatches> 
 
       </observers> 
 
      </catalog_block_product_list_collection>
如果你對此有何評論此代碼在產品列表頁面上不會看到色板。

在活動中添加您的觀察者方法以添加色板。

我希望這會有所幫助。信息頁面上

+0

感謝您的指針......有沒有更多的建議如何設置一個觀察員呢?我已經將(上面)塊複製到我的模塊config.xml中,但我確信除此之外還有更多。活動/觀察員對我來說真的很新 – user2682676 2015-02-11 17:29:22

0

添加色板是通過各種方式

我會爲您提供的方法來完成。

方法1: 您可以使用此模塊,它是免費的,或者你可以通過學習模塊

http://magebug.blogspot.in/2013/06/magento-how-to-display-color-options-in.html

Methos 2研究這樣做的方式: [這將顯示所有選項可配置產品]

<?php if($_product->isConfigurable()): ?> 
    //get attributes 
    <?php $attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product) ?> 
    <?php if(count($attributes)): ?> 
    <ul> 
    <?php foreach($attributes as $att): ?> 
     <?php $pAtt=$att->getProductAttribute(); 
     //get the child products 
     $allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product); 
     $frontValues =array() ?> 
     <li><?php echo $pAtt->getFrontendLabel() ?> 
     <ul> 
     <?php foreach($allProducts as $p): ?> 
     //check stock, status, ... 
     //do not show unsaleable options 
     <?php if(!$p->isSaleable()) continue; ?> 
     <?php $out=$p->getAttributeText($pAtt->getName()); ?> 
     <?php $frontValues[$out]=$out; ?> 
     <?php endforeach ?> 
     <li><?php echo implode('</li><li>', $frontValues) ?></li> 
     </ul> 
     </li> 
    <?php endforeach ?> 
    </ul> 
    <?php endif ?> 
<?php endif ?> 

您可以通過圖像或標籤替換下拉菜單。

希望這會爲你工作。

0

如果您在Mage_ConfigurableSwatches_Model_Observer看,你有

public function convertLayerBlock(Varien_Event_Observer $observer) 
{ 
    $front = Mage::app()->getRequest()->getRouteName(); 
    $controller = Mage::app()->getRequest()->getControllerName(); 
    $action = Mage::app()->getRequest()->getActionName(); 

    // Perform this operation if we're on a category view page or search results page 
    if (($front == 'catalog' && $controller == 'category' && $action == 'view') 
     || ($front == 'catalogsearch' && $controller == 'result' && $action == 'index')) { 

     // Block name for layered navigation differs depending on which Magento edition we're in 
     $blockName = 'catalog.leftnav'; 
     if (Mage::getEdition() == Mage::EDITION_ENTERPRISE) { 
      $blockName = ($front == 'catalogsearch') ? 'enterprisesearch.leftnav' : 'enterprisecatalog.leftnav'; 
     } elseif ($front == 'catalogsearch') { 
      $blockName = 'catalogsearch.leftnav'; 
     } 
     Mage::helper('configurableswatches/productlist')->convertLayerBlock($blockName); 
    } 
} 

正如你看到的,條件需要你路線($ front,$ controller,$ action)進行處理。您可以通過重寫並添加條件來覆蓋此觀察者。

相關問題