- Posts: 11
- Thank you received: 0
Generate product name from custom fields
11 years 1 month ago #210408
by Impress51
Generate product name from custom fields was created by Impress51
-- 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
-- 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.
11 years 1 month ago #210412
by nicolas
Replied by nicolas on topic Generate product name from custom fields
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
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.
11 years 1 month ago #212459
by Impress51
Replied by Impress51 on topic Generate product name from custom fields
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?
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.
11 years 1 month ago #212475
by nicolas
Replied by nicolas on topic Generate product name from custom fields
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:
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:
Code:
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.159 seconds