Alternate attribute names - product specific

Open to all! Ask other shopowners for help.
Post Reply
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Alternate attribute names - product specific

Post by LeeFoster »

Ok, I think this might be an interesting one.

I have not so much an issue but something I'd like to work around. I have some products on my shop that could use some of the same attributes if the wording could be changed.

Lets say I have 3 sets of attributes - primary colour, secondary colour & tertiary colour - each one has the same colours as options. 3 different products may then be available with a combination of those colour options.

Product 1 uses primary & secondary colour and they can be called Primary & Secondary
Product 2 uses primary, secondary & tertiary colour as above however tertiary would need to be called "Accent Colour"
Product 3 uses primary & secondary colour but in this instance they need to be called "Body Colour" and "Arms Colour"

Using the built in attributes system I would need at least 6 sets of the same options just to achieve this so if anyone has any suggestion on how to get around this it would be appreciated.


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Alternate attribute names - product specific

Post by ecartz »

Have you tried assigning the same option values to multiple options? An attribute links an option, an option value, and a product ID. So five options, each with duplicate values.

It's not clear to me if the interface supports this, but you could probably do it with SQL. Create five options in the interface (change to colour if your customers would prefer):

1. Primary color.
2. Secondary color.
3. Accent color.
4. Body color.
5. Arms color.

For one of them, you can assign the colors in the interface. If you can't assign the same color values to different options in the interface (try that first), use SQL directly to add the linkages to the products_options_values_to_products_options table. Then just create the attributes in the interface as normal. SQL examples: https://github.com/CE-PhoenixCart/Phoen ... l#L63..L64 (change the first column from numbers to NULL)

One way to generate the SQL would be to go to phpMyAdmin after you create the first set of colors in the interface. Export the products_options_values_to_products_options table. At that point, it will have entries for all the colors to the first option. Go through and manually change from the products_options_id for that from whatever it is then to the new one. Also change the products_options_values_to_products_options_id to NULL or delete that column entirely. You could post the exported SQL here for more help.

Perhaps it is obvious, but I'll say it explicitly anyway. Do this on a test store before you try it on a live shop. Note that the SQL will probably have to change somewhat from the test store to the live shop unless you copy the database from the live shop to the test store after creating the options (five color types, e.g. primary) and the values (six colors).
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: Alternate attribute names - product specific

Post by LeeFoster »

ecartz wrote: Fri Jan 06, 2023 11:01 am For one of them, you can assign the colors in the interface. If you can't assign the same color values to different options in the interface (try that first), use SQL directly to add the linkages to the products_options_values_to_products_options table. Then just create the attributes in the interface as normal. SQL examples:
This is how I did it to create secondary and accent colours originally, I was just trying to avoid having to have the exact same options 5 - 6 times when I think 3 would be enough


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply