News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Automatically generate product name from custom fields

Started by Dimi, December 17, 2018, 14:55:59 PM

Previous topic - Next topic

Dimi

Hello,
We are developing an eshop with cars and each product has a few custom fields (Brand, Modal, Year etc). The clients wants to add the custom fields to each product and the product name to be automatically generated by these fields.

I've found the product.php file in administrator -> components -> com_virtuemart -> controlers
and tried to change the value in line 59 like this:
$data['product_name'] = vRequest::get('field');
or
$data['product_name'] = $data['field']

When I make one of these changes, the product name becomes 'Array'. I suppose I have to get the array values and echo them in the $data['product_name'] but I don't know how.

Any help would be much appreciated.
Thank you.

PRO

This is best done with a plugin.

1st Way
Have all 3 (Brand, Modal, Year etc)   as parameters.
Then, use javascript to fill in product name on backend.

Inside the function    plgVmOnProductEdit  , just add the jQuery

With this way you have to be in the backend and manually save.

2nd Way
If you want to be able to upload products, csv etc.
Have all 3 (Brand, Modal, Year etc)   as product plugin parameters.
Then, you can change the name on the frontend via the parameters.





Studio 42

Why not dynamic change the name in the front-end.
The brand is mf_name, the year can be an existing date field
Modal ? you mean model ?
A problem is if you use customfields to set name, first time using Brand Modal Year, the name is for eg
Fordt fiesta 1990
On save again
Fordt fiesta 1990 Fordt fiesta 1990
On save again
Fordt fiesta 1990 Fordt fiesta 1990 Fordt fiesta 1990
...
So this solution is not suitable for your needs