1

我正在使用 Magento 1.9.1.0 并且在类别和产品视图页面上有可配置的样本。

我正在尝试创建一个列出所有产品的自定义“商店”页面(商店只有 +/-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>

我还在 configureswatches.xml 中添加了对页面的页面引用

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

它将适当的 .js 文件加载到页面......但是没有显示样本。

有人对我如何做到这一点有任何建议吗?我必须在这里遗漏一些明显的东西..

谢谢!

4

4 回答 4

1

尝试在 mystore_site_index_shop 块之后的 local.xml 文件中添加产品列表更新。

在 local.xml 里面

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

- 编辑 -

即使我能够使用我上面发布的方法来完成这项工作。根据我的理解,正确的方法是将您的整个主题构建为 rwd 主题的子主题,从而允许您在没有任何技巧的情况下使用色板。

在 app/design/frontend/YOURTHEME/default/etc/theme.xml 里面

<?xml version="1.0"?>
<theme>
<parent>rwd/default</parent>
</theme>
于 2015-02-14T15:59:09.303 回答
1

如果您转到 app/code/core/Mage/ConfigurableSwatches/etc/config.xml,您将在第 83 行的 catalog_block_product_list_collection 事件中看到观察者。

  <catalog_block_product_list_collection>
                <observers>
                    <configurableswatches>
                        <class>configurableswatches/observer</class>
                        <method>productListCollectionLoadAfter</method>
                    </configurableswatches>
                </observers>
            </catalog_block_product_list_collection>
如果您评论此代码,您将不会在产品列表页面上看到样本。

在事件上添加您的观察者方法以添加样本。

我希望这有帮助。

于 2015-02-11T05:33:37.633 回答
1

在列表页面上添加色板是通过各种方式完成的

我会为你提供方法。

方法一: 你可以使用这个免费的模块,也可以通过学习模块来学习做事的方法

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

方法 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 ?>

您可以用图像或标签替换下拉菜单。

希望这对你有用。

于 2015-02-11T07:22:21.713 回答
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) 来处理。您可以通过重写并添加您的条件来覆盖此观察者。

于 2017-09-26T15:24:19.827 回答