I'm a bit of a Joomla noob so hopefully this is an easy problem.

We have a Joomla 3.8.11 website using J2Store 3.3.0, and the client wants to add the SKU values to the product aliases. Specifically we want the alias generation procedure to be like

make alias based on title in the usual way;
if (SKU is set):
  append SKU to the alias;
check for duplicates in the usual way;

We want everything else to behave the same way, we only want to append a value to the alias when it's being automatically generated. Is there a simple way of doing this?

What I've tried so far:

I'm looking at the MVC Component tutorial and they subclass JModelAdmin and then override the save() function. Their situation has more alterations than mine so it's hard to see what exactly I need, and moreover J2Store is based on f0f so it uses F0FModel instead.

What I did find was a class called J2StoreModelOptions that subclasses F0FModel in


with a save($data) function that might be what I need to alter. However I added a console message to the function's body but when I click "Save" on an article's edit page it doesn't get logged, so maybe I'm not in the right place. If someone knows an easier way or if they know that I'm doing something wrong it would be very helpful. (I have submitted a support request to J2Store but we're in different timezones and I would like to resolve this asap, and I will probably still need some help once I've heard a response)

1 Answer 1


No, there is no simple way to this. At least, simple means a lot of things for everybody here. I will give you some good directions on this however.

First of all, J2Store has Simple products, variable products, configurable products, flexible products...etc. So how do you think it's simple? Then there is the content component which handles the articles, quite complex component, J2Store is a different, also very complex component with at least 10 different database tables or more.

If you just want to override the content component's core file which is creating the Alias field, then you will lose that override at the next Joomla update. It is better to not doing so. Thus:

1. you have to create a content plugin (google: creating content plugins for Joomla 3) and please also visit this link: https://docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla

2. Article alias field is created in yourjoomla/administrator/com_content/models/article.php file around line 642. in the code (that is still easy to find. Well, if someone know where to look for this. You can screw things up heavily here though, be careful).

3. The plugin has to operate on onContentBeforeSave event. So your function has to operate on that event. Or you can also create a J2Store plugin and do something similar if you want to handle sku creating at article creating together (two different component is working here). So it is a bit complex to figure out from which approach you will have to use. But I think the content plugin is the better choice for this.

4. You have to create a function which gets the database->j2store products, variants and so on tables, and gets the Product data (like product_sku) from these tables, based on product_source_id which is equal to article_id and join the query for variant_id and sku from variant products to variants table, if your client has these kind of products (it's possible).

5. You can get the database and db tables with $db = JFactory::getDbo(); line and you can create query objects to get the data with $query = $db->getQuery(true); . You have to study this a bit here: https://docs.joomla.org/Selecting_data_using_JDatabase

So, you just have to put the above together and you are done :) I just can wish you good luck for the project and ask higher salary from your client for this project. :)

I hope I helped you to get some light on how to start with your special project (however the above is not an exhaustive list of tasks at all, it's just a very fast skeleton).

  • Thank you very much for your answer, it's looking much more complicated than I expected (I thought I would only have to change two lines somewhere in the J2Store component or something). In light of that it might be easier to add a button somewhere that the client can click on which just updates the aliases in the database, so I don't have to worry about intercepting an onContentBeforeSave event and making sure everything fits together. Would something like this be appropriate, or might I run into unexpected issues?
    – William
    Jan 29, 2019 at 17:18
  • @you - if the client clicks on a button of course it could work too, however for that you have to hack for example the product edit view of J2Store which hack can get lost also if you update the J2Store component. Still the content plugin would be the simplest, but if you are not that familiar yet with Joomla, you can get lost with that too. There is a possibility of finding easier way for this but it would take few hours to figure it out. I have not checked more deeply yet how content component and J2Store component (or a plugin of that) saves SKU together with the article.
    – Zollie
    Jan 29, 2019 at 17:30
  • @you - but I am sure that J2Store also has a content plugin onarticlesaving otherwise it could not work. So you have to also check that if in J2Store plugin on content, how you could find a way to insert something in that plugin when a product is created by J2Store from an article. At that point you could do it in easier way.
    – Zollie
    Jan 29, 2019 at 17:33
  • 1
    I sat down and learned how to write a plugin, and it was not so bad! I wrote a content plugin for the onContentBeforeSave function, and to access the J2Store parameters I mimicked what was done in the J2Store content plugin. Now I can just install the plugin instead of shoving code into an already heavy J2Store class.
    – William
    Jan 29, 2019 at 23:28
  • 1
    @you - you will find it in #__j2store_variants table :) it looks like that j2sotre saves all products as variants also, so that is why (this was just my conclusion after a short checking of the table structure)
    – Zollie
    Jan 31, 2019 at 20:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.