Magento2 Back End is working fine but front end is not working and showing This page isn’t working error

Magento2 Back End is working fine but front end is not working and showing This page isn’t working error

September 18, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento2 Back End is working fine but front end is not working and showing This page isn’t working error

Magento2 Front End Not Working: Solving the “This Page Isn’t Working” Error

Dear developer,

I understand your frustration when your Magento2 project suddenly stops working without any apparent reason. The error logs often provide valuable clues about what went wrong, and in this case, the fatal PHP type error points us towards a specific issue.

Understanding the Error: TypeError Argument 1 Passed to Magento\Catalog\Model\ResourceModel\Product\Collection::addIsSaleableAttributeToFilter()

The error message clearly indicates that there is an issue with how data is being passed to the Magento\Catalog\Model\ResourceModel\Product\Collection class. The method addIsSaleableAttributeToFilter() expects either an array or null as its first argument, but it received an integer instead.

Tracing the Error: Line by Line Analysis

Let’s follow the stack trace to understand where this error is originating:

  1. Line 1582 in vendor/magento/module-catalog/Model/ResourceModel/Product/Collection.php: The error is happening at this line when calling addIsSaleableAttributeToFilter(1). Here, the integer value 1 should be an array or null.

  2. Line 56 in app/code/Smartwave/Filterproducts/Block/Home/LatestList.php: This extension seems to be causing the issue by incorrectly passing a boolean value (1) as an argument instead of an array. The line calls $collection->addAttributeToFilter('is_saleable', 1, 'left') without using the required second parameter for array values.

  3. Line 33 in app/code/Smartwave/Filterproducts/Block/Home/LatestList.php: This is where the getProducts() method is defined and called, likely from a frontend controller or phtml file.

Identifying the Solution: Fixing the PHP Type in Smartwave/Filterproducts Extension

The root cause of this issue seems to be an incorrect data type being passed from your custom extension. The addAttributeToFilter method requires three parameters:

  • Attribute code (is_saleable)
  • Condition (usually an array)
  • Direction (“left” or “right”)

In your case, you’re passing 1 instead of an array containing the condition and value. Here’s how it should be correctly implemented:

$collection->addAttributeToFilter(
    'is_saleable',
    ['eq' => 1],
    'left'
);

Or if you want to filter saleable products with a status of 1:

$collection->addAttributeToFilter(
    'status',
    ['neq' => 0]
);

Best Practices for Resolving Magento2 Type Errors

When dealing with type errors in your custom extensions, always check:

  1. The required parameters and their types in the core Magento classes.
  2. Ensure you’re following the correct syntax for method calls.
  3. Avoid mixing and matching data types when passing arguments.

Next Steps: Testing the Fix and Further Troubleshooting

Once you’ve updated the filter condition in your LatestList.php file with the corrected array syntax, clear your cache using:

bin/magento cache:clean

Then run your Magento application again. If the error persists, review your entire codebase for any other instances where you might be passing incorrect data types to core methods.

Conclusion

Debugging type errors in Magento2 often requires a deep understanding of how the framework handles data and method calls. By carefully analyzing the stack trace and the error message itself, we can identify the root cause and apply the necessary fixes.

Remember, when working with custom extensions or overriding core classes, always ensure you’re adhering to the correct syntax and data types required by the Magento2 platform. This will help you avoid type errors and maintain a stable application.

If this solution doesn’t resolve your issue, feel free to reach out for more specific guidance. For in-depth tutorials on Magento2 development and best practices, don’t forget to check out our resources at Laravel Company.

Happy coding!

Magento 2 Catalog Extensions Errors

Our network