2 minutes November 1, 2024

How to Manage Inactive Products in Shopware

When integrating orders from another e-commerce platform into your Shopware shop, you may need to include items that are inactive in Shopware within these orders. This article explains the issue and provides a solution to store these deactivated items in Shopware orders.

Issue Faced

When integrating orders from another e-commerce platform into the Shopware system, there is no need to display these items on the Shopware frontend, so we have deactivated them. However, deactivated items cannot be retrieved using the SalesChannel product repository when inserting ERP orders into Shopware.

The default restriction within Shopware limits the visibility of products based on their active status, preventing inactive products from being fetched.

Default Product Availability Filter

By default, Shopware uses the ProductAvailableFilter class to determine which products are available for a given sales channel. The relevant code snippet is as follows:

 

 

In this filter, the line new EqualsFilter('product.active', true) ensures that only active products are returned.

Solution: Customizing Product Filters

To retrieve inactive products in Shopware, you need to extend the ProductAvailableFilter to modify the behavior of the product retrieval process. Below is a step-by-step solution:

Step 1: Create a Custom Filter

You can create a custom filter class that extends the existing ProductAvailableFilter. Here’s how:

In this custom filter, you override the visibility setting to allow fetching inactive products.

Step 2: Implement the Custom Filter in Your Code

Use your CustomProductAvailableFilter in place of the default ProductAvailableFilter when you are querying the product repository:

Conclusion

These steps allow you to successfully modify the default behavior of Shopware’s product filtering system. This allows you to retrieve inactive products when integrating orders from another e-commerce platform. By carrying out this customization, you will have greater control over which products are visible and accessible in your Shopware shop. If you’re looking for a reliable Shopware agency to help with your e-commerce needs, feel free to reach out to us.

blog
Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
Aneesh ceo
Aneesh Sreedharan
Founder & CEO, 2Hats Logic Solutions
Subscribe to our Newsletter
Aneesh ceo

    Stay In The Loop!

    Subscribe to our newsletter and learn about the latest digital trends.