cancel
Showing results for 
Search instead for 
Did you mean: 

addTierPriceData() is extremely slow

addTierPriceData() is extremely slow

I'm trying to get a collection for the Block module I'm writing and for some reason when I add addTierPriceData() to the collection it becomes very slow and memory usage increases considerably.

 

For example the code below for my data set (7000 products) executed in about 12 seconds and uses 123MB of RAM.

 

			$collection = Mage::getModel('catalog/product')
				->getCollection()
				->addAttributeToSelect($attributes)
				->addAttributeToSelect('featured')
				->addAttributeToSelect('*')
				->addMinimalPrice()
				->addFinalPrice()
				->addTaxPercents()
                                ->addTierPriceData()
				->addUrlRewrite()
				->setStoreId($this->_storeId)
				->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
				->addAttributeToFilter(array(array('attribute' => 'category_id','in' => array($catids))));

 

If I remove addTierPriceData() it executes instantly and uses only 4 MB of RAM.

 

			$collection = Mage::getModel('catalog/product')
				->getCollection()
				->addAttributeToSelect($attributes)
				->addAttributeToSelect('featured')
				->addAttributeToSelect('*')
				->addMinimalPrice()
				->addFinalPrice()
				->addTaxPercents()
				->addUrlRewrite()
				->setStoreId($this->_storeId)
				->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
				->addAttributeToFilter(array(array('attribute' => 'category_id','in' => array($catids))));

 

 

What could be the problem?

 

I'm running Magento 1.9.0.1.

1 REPLY

Re: addTierPriceData() is extremely slow

How many products are you trying to load?

Magento Moderator since 2009
Keep Calm and Clear Cache!