If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Categories, Products, Attributes / Adding an attribute to all products using SQL command?

Adding an attribute to all products using SQL command?

Locked

Started by arniesbarmyarmy on 13 Oct 2009, 11:13 AM · Views: 1,644

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
13 Oct 2009, 11:13 AM
#1
arniesbarmyarmy avatar

arniesbarmyarmy

New Zenner

Join Date:
Aug 2009
Posts:
40
Plugin Contributions:
0

Adding an attribute to all products using SQL command?

Hi, I would like to add a "Please select ..." as an attribute. I can do this for one product easily but i have hundreds of products that i would like to add this to. So I was wondering if there was a quick way of doing this? Perhaps an SQL command?

The sort of procedure that I want to do is:

  • if the product has an attribute for size
  • then add the "please select" option
  • set Used for Display Purposes Only = YES
  • set Default Attribute to be Marked Selected = YES

any suggestions would be much appreciated.. thanks

14 Oct 2009, 2:26 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding an attribute to all products using SQL command?

Backup your database ...

Did you back it up?

If you did not back it up ... you will be doomed ... :eek:

Now that you have backed up your database ... go to the Catalog ... Option Values Manager ...

Down at the bottom of the screen, just above the last grey box you will see the instructions:

Copy Option Name/Value to Products with existing Option Name ...
Select an Option Name and Value that currently exists on a product or products to add to all products or to only the products in the selected category that have the selected Option Name.
Example: Add Option Name: Color Option Value: Red to all Products with Option Name: Size
Example: Add Option Name: Color Option Value: Green with default values from Products ID: 34 to all Products with Option Name: Size
Example: Add Option Name: Color Option Value: Green with default values from Products ID: 34 to all Products with Option Name: Size for Categories ID: 65

Let's say I have an Option Name: Size and I want to add the Option Value Please Select to all Option Name Size ...

Pick from the first dropdown set:
Option Name to add: Size
Option Value to add: Please Select

Option Name to add to: Size

Leave set to the Radio Button: Ignore existing attributes and add only new attributes

And then, as you have backed up your database first, hit Insert ...

This will add that new Option Value for Size to all Products that have at least 1 Attribute for Option Name: Size ...

Nifty eh?

Now, to set the settings for that to be Default and Display Only, you need to get the options_id and options_values_id from the products_attributes table ... and you can learn the rest of the story ... :cool:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

19 Oct 2009, 1:57 PM
#3
arniesbarmyarmy avatar

arniesbarmyarmy

New Zenner

Join Date:
Aug 2009
Posts:
40
Plugin Contributions:
0

Re: Adding an attribute to all products using SQL command?

Thank you so much for the advice!! It all worked perfectly, which has saved me a lot of time!

In case anyone would like to know, the SQL query I used was:

UPDATE products_attributes SET attributes_display_only = 1 WHERE options_values_id = 56; (Where the 56 is the ID for the "Please select" option)

Thanks Linda, much appreciated! :clap:

20 Oct 2009, 2:47 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Adding an attribute to all products using SQL command?

Some bunny is reading between the lines ... :cool:

Thanks for the update and posting ... the rest of the story ... :flex:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!