Is it possible for the Product Spotlight to choose products randomly? Currently, I have about 10 featured products, and I notice that the Product Spotlight only uses the last 3 items I made featured products instead of randomly selecting from all featured products.
Does anyone here know how to do this?
Thanks
11 answers
bump to the top
Someone please help me with this.
I am still waiting for help with this.
Hi there,
I am sorry for my delay.
For your case, please kindly try with my guider:
+ Open app\code\local\JoomlArt\JmProductsSpotlight\Block\ List.php file, at about line 258, find following code:
Code:
->where("ea.attribute_code='featured'");
and change to:
Code:
->where("ea.attribute_code='featured'") ->order("rand()");
Hope it helps.
I really appreciate your reply. This problem has been driving me crazy in trying to figure out and I couldn’t. I will try this now.
Hello JA Developer.
Unfortunately it does not work. The products are still not listed at random.
I will await your reply.
Hi dwpegues,
In this function, find following code:
Code:
$list = $this->getListBestBuyProducts( 'updated_at', 'desc', $product_ids);
and change to:
Code:
$list = $this->getListBestBuyProducts( 'rand()', '', $product_ids);
Unfortunately, it is still not working.
Any other modifications or suggestions?
Hi
I solved this issue to help you.
Please see my code:
Code:
function getListBestBuyProducts($fieldorder='ordered_qty', $order='desc', $product_ids='', $perPage=NULL, $currentPage=1){ $list = null; /* Always set de $perPage, by template or by config if $perPage eq 0 (zero) not limit the list */ if($perPage === NULL) $perPage = (int) $this->_config['qty']; /* Show all the product list in the current store order by ordered_qty, showing the bestsellers first */ $storeId = Mage::app()->getStore()->getId(); $products = Mage::getResourceModel('catalog/product_collection') ->setStoreId($storeId) ->addAttributeToSelect('*') ->addStoreFilter($storeId) ->setOrder($fieldorder, $order); $products->getSelect()->order('rand()'); if ($product_ids) { $products->getSelect()->where("e.entity_id in ($product_ids)"); } /* Filter list of product showing only the active and visible product */ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products); $products->setPageSize($perPage)->setCurPage($currentPage); $this->setProductCollection($products); if (($_products = $this->getProductCollection()) && $_products->getSize()){ $list = $_products; } return $list; }
I see that you were able to get the random feature working. I would love to know how you did it.
Thanks JA Developer
There it is… you posted the solution as I wrote my last email. In your post, it does not have the option to ‘Mark Best Answer’
I have checked on my site, and it works perfectly.
By any chance will you sticky this? I am sure there are a lot of others that will want to do this.
Thanks so much again!!!
This question is now closed