Generate product name from custom fields

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
9 years 3 months ago #210408

-- url of the page with the problem -- : www.impress51websites.co.uk/tophat/
-- HikaShop version -- : 2.5.0 Business
-- Joomla version -- : 3.4.3
-- PHP version -- : 5.5
-- Browser(s) name and version -- : Firefox 39.0

Hi,

I have three custom fields setup as text/dropdowns and all three are required. I'd like to populate the product name based upon these values as follows:

productName = artist . ' - ' . album . '(' . type . ')';

Which files would I need to override to achieve this?

Kind Regards

Jaz

Please Log in or Create an account to join the conversation.

  • Posts: 82866
  • Thank you received: 13373
  • MODERATOR
9 years 3 months ago #210412

Hi,

The best would be to create a custom HikaShop plugin and implement the onBeforeProductUpdate and onBeforeProductCreate triggers in your plugin and force the value of the product name based on these fields.
www.hikashop.com/support/support/documen...ntation.html#product

Please Log in or Create an account to join the conversation.

  • Posts: 11
  • Thank you received: 0
  • Hikashop Business
9 years 2 months ago #212459

Hi,
I have created the plugin (attached files) and it works, but when the quantity is updated when a customer adds it to their cart it runs then too and messes up the changes, how do I stop this from happening?

Please Log in or Create an account to join the conversation.

  • Posts: 82866
  • Thank you received: 13373
  • MODERATOR
9 years 2 months ago #212475

The problem is in your plugin's code.
Of course, the product will be updated each time it is necessary. When the stock changes, even when someone merely display the product page (in order to update the hit count), etc.
It's your job in the plugin to do your processing only when necessary.
So you should add a condition like this:

if(!isset($product->album) || !isset($product->type) || !isset($product->artist))
 return;

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum