【问题标题】:Random Products magento showing 2 fixed products everytime随机产品 magento 每次显示 2 个固定产品
【发布时间】:2012-08-14 07:54:48
【问题描述】:

我正在使用 magento 的默认随机产品块。因为它在今天之前工作正常。但现在每次只显示两个固定产品。我设置了 5 个产品的限制。

突然间,它的行为很奇怪。

这是我在随机块中的代码

  protected function _getProductCollection()
    {
        if (is_null($this->_productCollection)) {
            $collection = Mage::getResourceModel('catalog/product_collection');
            Mage::getModel('catalog/layer')->prepareProductCollection($collection);
            $collection->getSelect()->order('rand()');
            $collection->addStoreFilter();
            $numProducts = $this->getNumProducts() ? $this->getNumProducts() : 0;
            $collection->setPage(1, $numProducts)->load();

            $this->_productCollection = $collection;
        }
        return $this->_productCollection;
    }

这是我在主页 CMS 页面中的块代码。

{{block type="catalog/product_list_random" name="product_random" num_products="5" template="catalog/product/random.phtml"}}

这是我在模板文件中的调用。

$_productCollection=$this->getLoadedProductCollection();

更烦人的事情是,如果我在管理站点中将产品设置为新产品,该产品会显示在随机产品列表中。 到底是怎么回事?

【问题讨论】:

    标签: php magento


    【解决方案1】:

    哎呀!这又是一个重新索引问题!!!。

    重新索引后,随机产品块按预期工作。

    发生了什么事,Magento 只从新创建/更新的产品中挑选随机产品。

    晚上重新索引的猜测让我度过了一个愉快的夜晚。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-22
      • 2015-12-30
      • 1970-01-01
      相关资源
      最近更新 更多