简体   繁体   English

随机产品magento每次显示2个固定产品

[英]Random Products magento showing 2 fixed products everytime

I am using magento's default random product block. 我正在使用magento的默认随机积块。 As it was working fine before today. 由于今天之前工作正常。 but now it is showing only two fixed products every time. 但是现在每次只显示两个固定产品。 I have set a limit of 5 Products. 我设置了5个产品的限制。

Suddenly, It is behaving strange. 突然,它表现得很奇怪。

This is the code I have in Random block 这是我在随机块中的代码

  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;
    }

and this is the block code I have in Home CMS page. 这是我在Home CMS页面中的阻止代码。

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

and this is my call in template file. 这是我的模板文件调用。

$_productCollection=$this->getLoadedProductCollection();

One more annoying thing is if I set a product to be new in admin site that is showing in the random product list. 另一个烦人的事情是,如果我将某个产品设置为随机产品列表中显示的管理站点中的新产品。 What the hell is going on? 这到底是怎么回事?

Opps! 哎呀! That was a re-index issue again!!!. 那又是重新编制索引的问题!!!

After reindexing, Random products block works as expected. 重新索引后,Random products块将按预期工作。

What's happening, Magento only picking up random products from newly created/updated products. 发生了什么,Magento只从新创建/更新的产品中随机挑选产品。

Just a guess of reindexing in the evening made my night. 晚上只是重新索引的猜测就让我难过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM