0

We have a custom Model override that works beautifully in developer mode, it has conditions to load classes based on the page the user is on. These conditions are ignored when the Magento is switched to production mode and only one condition is read based on the static generated content.

Is there any way to exclude Model or other overrides from the production mode static content generation?

Sample code:

namespace Module\Catalog\Model;

if ($available) 
    {
        class ProductPlugin
                {
                        $collection->joinField(
                            'is_in_stock',
                            'cataloginventory_stock_item',
                            'is_in_stock',
                            'product_id=entity_id',
                            '{{table}}.stock_id=1',
                            'left'
                        )->addAttributeToFilter('is_in_stock', array('eq' => 0))->getSelect()->order(['is_in_stock desc']);
                }
    }
   else
    {   
       class ProductPlugin
       {

       }
    } 

As soon as the site is deployed in production the conditionals are not processed.

4
  • Please share your code
    – PЯINCƎ
    Jul 25, 2018 at 9:44
  • what is this $available and why not using that condition in class.
    – kunj
    Jul 25, 2018 at 10:00
  • Hello, I've tried using the conditions within the class too but it makes no difference as the result is the same in production mode. We're basically comparing different pages to retrieve a different a set of data/sort order from the database. Jul 25, 2018 at 11:00
  • I've resolved this, the problem was that the override was not being called at all in production. I separated it into a proper module with registration.php, composer.json etc and it's working great! Jul 25, 2018 at 14:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.