#440 Override method

Posted in ‘Technical Support / Bugs’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by Olivier on Sunday, 31 August 2025 21:50 UTC

S derjan

Hi dear

Is there a way to override the _sfBuildWhereQuery and _sfBuildQueryJoins methods in the file https://github.com/j2commerce/j2cart/blob/main/administrator/components/com_j2store/models/products.php through Joomla MVC or by creating a plugin?

Olivier

Hello,

theorytically, you can override the model with the class loader, but I have not tested it.

You could package it in a plugin in the onAfterInitialise() function (\JLoader::register...).

May I ask you what you need to change in the queries? Something that could benefit other users?

Thank you!

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

S derjan

I tried a lot but I didn't succeed, could you please help me with the code? Maybe I made a mistake somewhere. I want to display articles that have not yet been converted into product in the products list.

Olivier

Well this is a rather complicated process and a bit out of scope from regular support, not sure you really want to go to that rabbit hole.

Here is an example of a plugin that would override the admin Products model.

Installation:

1. Unzip then install the included zipped plugin through Joomla's extension manager
2. Enable "System - J2Store Products Override" in Plugin Manager
3. Set "Enable Override" to "Yes" in plugin configuration
4. The override will automatically activate when J2Store is used

Customization:

Edit plugins/system/j2store_products_override/models/products.php to:
- Add your custom logic to processCustomProductLogic()
- Override additional methods from the original model
- Add new custom methods
- Modify database queries in getProductListQuery()

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

S derjan

Thank you very much Olivier, you really helped me a lot. I meant exactly the override structure, thanks again.

Olivier

You are very welcome!

Olivier.

Growing Together

Help us get back to #1 in the Joomla Extension Directory by leaving us a 5-Star review here.

Stay Updated

Subscribe for free and be the first to know about the latest features, updates, and new additions.