Zen Cart Logo
Forums / General Questions / adding attributes to all products with sql query

adding attributes to all products with sql query

Views: 1,229

Results 1 to 9 of 9
21 Aug 2013, 2:41 PM
#1
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

adding attributes to all products with sql query

I have a large cart that needs the same three attributes added to every product. Some products already have them but many don't. I'm trying to do a sql query to do it all at once and have realized it's dang complicated.

Esentially it would say if all products don't have these three attributes, add the attributes.

I don't think any of the mass attribute functions can do this except to copy over category by category. If there's another way, I would love to hear about it. Otherwise...sql query.

21 Aug 2013, 2:45 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: adding attributes to all products with sql query

Probably can't be done with a typical single SQL query.

The built-in mass copiers use PHP code to read existing data, determine what changes are needed, and then do the appropriate inserts as required.
Use the right tool for the job ;)

21 Aug 2013, 3:18 PM
#3
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: adding attributes to all products with sql query

So then we need to do the copy to category manually? - and there are a lot of categories...

21 Aug 2013, 3:19 PM
#4
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: adding attributes to all products with sql query

Since some of the product already have one of the attributes and we don't want that changed, we would be doing the Ignore and add only new attributes choice correct?

23 Aug 2013, 4:30 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: adding attributes to all products with sql query

Is there anything different about the Products with the 1 Attribute already added vs the way you want the Attributes to be for all Products on the site?

22 Apr 2014, 12:14 PM
#6
refinerztouch avatar

refinerztouch

New Zenner

Join Date:
Mar 2014
Location:
USA
Posts:
10
Plugin Contributions:
0

Re: adding attributes to all products with sql query

delia:

Since some of the product already have one of the attributes and we don't want that changed, we would be doing the Ignore and add only new attributes choice correct?

Hi there, I am having the same issue . So far I have not added any attributes to my products. is there a way to insert attributes 'size' and 'color' at once. i am having 200 pruducts and they are too much to go one by one. would appreciate for any help.

Thank you in advace!!!

22 Apr 2014, 12:18 PM
#7
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: adding attributes to all products with sql query

I expect we did do it category by category instead of with a query. It's been too long ago to remember details but that's probably what we had to do.

22 Apr 2014, 4:42 PM
#8
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: adding attributes to all products with sql query

refinerztouch:

Hi there, I am having the same issue . So far I have not added any attributes to my products. is there a way to insert attributes 'size' and 'color' at once. i am having 200 pruducts and they are too much to go one by one. would appreciate for any help.

Thank you in advace!!!

One way, although requires installation of a plugin and some learning would be to use something like easy populate or apsona. If there are changes desired to be made en mass in the future, I would recommend that route. Otherwise, there are several database like modifications that can be made, delia for example suggested grouping all items within one or more categories and then could update the database based on that one or more categories. If it is all products, then things become a little easier as there is no longer a limit applied to what to modify. For some reason I thought that the admin panel had such an "apply attribute to all products" type option. But I could be wrong, I haven't had to use it.

22 Apr 2014, 6:40 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: adding attributes to all products with sql query

delia:

I expect we did do it category by category instead of with a query. It's been too long ago to remember details but that's probably what we had to do.
As delia indicated, you can use the feature built into Catalog->Attributes Controller to copy the currently displayed product's attributes to all products within a category (I don't know when this feature was implemented; it might not be in v1.3.9h).

Essentially, you display a product that contains the attributes that you want to copy. You'll see at the top of the Attributes Controller display a set of buttons; the one on the far righthand side is "Copy To" with a link to "CATEGORY" below it. Click that button and you can select the category for which all products are to be set to include the attributes for that currently-displayed product! Granted, it's on a category-by-category basis, but the feature is already there.