Em Andamento

Change random selection method in a function in Magento

Our Magento installation has a home page block which displays a random selection of products from a given category. It works, but it's really slow. I tracked the culprit down to the following function:

protected function _getProductCollection()

{

if (is_null($this->_productCollection))

{

$categoryID = $this->getCategoryId();

if($categoryID)

{

$category = new Mage_Catalog_Model_Category();

$category->load($categoryID);

$collection = $category->getProductCollection();

}

else

{

$collection = Mage::getResourceModel('catalog/product_collection');

}

Mage::getModel('catalog/layer')->prepareProductCollection($collection);

if ($this->getIsRandom())

{

$collection->getSelect()->order('rand()'); // REALLY slow, approx 4000ms at 25k products

}

$collection->addStoreFilter();

$productCount = $this->getProductCount() ? $this->getProductCount() : 8;

$collection->setPage(1, $productCount)

->load();

$this->_productCollection = $collection;

}

return $this->_productCollection;

}

Specifically, it is the $collection->getSelect()->order('rand()'); statement that is extremely slow, adding around 4000ms to our time to first byte at our current product count of ~25k. Simply disabling randomness shaves about 3700ms off our page load time.

I would like to perform the randomization at application level, rather than use the notoriously slow MySQL ORDER BY RAND() method. Specifically, I would like you to implement the method described here: [url removed, login to view]

The deliverable is the updated _getProductCollection() function pasted above, modified to use an application level randomization method. The suggested solution is one, but you're free to use any method you choose, as long as it works and it's fast.

Habilidades: Magento, PHP, Zend

Ver mais: selection, random, method, magento slow, magento catalog, adding products to magento, random page, magento layer, byte time, magento change order product, magento product block, function order, magento product questions, php mysql product catalog, function time, random random, page load time magento, magento method, magento slow mysql, thumbs thumbs php mysql, Method Statement, use method, thumbs mysql php, magento return order, return order magento

Acerca do Empregador:
( 4 comentários ) Stockholm, Sweden

ID do Projeto: #5142133

Premiar a:

bojanpc

Hi, i can fix it in a hour. Thanks, Bojan .

$35 USD em 1 dia
(59 Avaliações)
5.8

7 freelancers estão ofertando em média $38 para este trabalho

dannv

Hi, I was working with magento from 2008. I often provide Magento extension and Magento theme. I have exp with upgraded, import data, themes, tax, payment, sales, shipping, SEO, etc... Please see my profile for mor Mais

$34 USD em 1 dia
(240 Comentários)
7.2
evidcomm

Hello Hiring manager, Greetings from Evidcomm!!! We have gone through your requirements and would be pleased to work on. We have already done this kind of work in past and surely we will get finished this project Mais

$40 USD em 1 dia
(39 Comentários)
5.9
zyeloncomputech

Hi sir, Thank you for giving opportunity for biding... we have gone through your requirements and we can Change random selection method in a function in Magento according to your exact requirements. Please Befo Mais

$53 USD em 1 dia
(19 Comentários)
4.9
shreeyait

Hello Sir, We have checked your job detail and as per that we are able to do your job and we have very good experience in Word Press, Joomla, Joomla component, Modules, PHP, HTML,Magento etc . As well knowledge on Mais

$53 USD in 5 dias
(13 Comentários)
4.0
DpDesignsPete

The randomization method you linked to on Stack Overflow looks like a good solution to me. I would implement this change inside a new module (in the local code pool) so that no core code is altered. I have prior Ma Mais

$55 USD in 2 dias
(2 Comentários)
3.3
monyetwang

Hi, That is a simple task. With my 5 years magento development I would love to do more for you in the future issues if you have. Please contact me via skype ndthan25 and I will change it for you. Regards,

$25 USD em 1 dia
(0 Comentários)
0.0
richardmagrath

I am Magento webstore developer and Magento designer have worked on it since it was first launched in the market in the year of 2007. I have a high level of expertise in custom building extensions, modules and plugins Mais

$25 USD em 1 dia
(0 Comentários)
0.0