Thursday, 3 November 2016

Magento2: getting Fatal error: Allowed memory size of error when tried to do mass status change action in magento from admin catalog grid


I was surprised to see core magento error in admin when i tried to attempt to change 100 products of the current status to other
ofcourse my catalog was aroung 7lakh items.
I and My team mate got the fix for this
Error is:
Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 24 bytes) in G:\xampp\htdocs\mage-ee206\vendor\magento\zendframework1\library\Zend\Db\Statement\Pdo.php on line 291


Fix we found here is 
vendor/magento/module-catalog/Controller/Adminhtml/Product/MassStatus.php

====
/**
     * Update product(s) status action
     *
     * @return \Magento\Backend\Model\View\Result\Redirect
     */
    public function execute()
    {
        $collection = $this->filter->getCollection($this->collectionFactory->create());
        $productIds = $collection->getAllIds();
        $storeId = (int) $this->getRequest()->getParam('store', 0);

        $status = (int) $this->getRequest()->getParam('status');

---------------
We changed to 
We extended the code module to our name space to extend core controller

/**
     * Update product(s) status action
     *
     * @return \Magento\Backend\Model\View\Result\Redirect
     */
    public function execute()
    {
    $productIds = $this->getRequest()->getPostValue("selected");
        $storeId = (int) $this->getRequest()->getParam('store', 0);
        $status = (int) $this->getRequest()->getParam('status');

==============
Now we could able to do Mass status change action without fail.

I hope it may help you.

Note: if you face the same error for Mass delete action also, you can try this. i have not tested that.
i will post once i tested it.

Cheers:)

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home