Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Bulk add attributes to all products

Bulk add attributes to all products

Views: 924

Results 1 to 3 of 3
26 Apr 2012, 1:06 AM
#1
buildingblocks avatar

buildingblocks

Totally Zenned

Join Date:
Jun 2008
Posts:
629
Plugin Contributions:
0

Bulk add attributes to all products

I have one option name/option value that I would like to add to 5,000+ products. Can this code be altered so I can run it in phpmyadmin so it will this same option name/option value to all products?

INSERT INTO username_zen2.zen_products_attributes (products_attributes_id, products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order, product_attribute_is_free, products_attributes_weight, products_attributes_weight_prefix, attributes_display_only, attributes_default, attributes_discounted, attributes_image, attributes_price_base_included, attributes_price_onetime, attributes_price_factor, attributes_price_factor_offset, attributes_price_factor_onetime, attributes_price_factor_onetime_offset, attributes_qty_prices, attributes_qty_prices_onetime, attributes_price_words, attributes_price_words_free, attributes_price_letters, attributes_price_letters_free, attributes_required) VALUES ('1074', '8368', '1', '1', '0.0000', '+', '0', '1', '0', '+', '0', '0', '1', NULL, '1', '0.0000', '0.0000', '0.0000', '0.0000', '0.0000', NULL, NULL, '0.0000', '0', '0.0000', '0', '0');[...]";

26 Apr 2012, 5:50 PM
#2
buildingblocks avatar

buildingblocks

Totally Zenned

Join Date:
Jun 2008
Posts:
629
Plugin Contributions:
0

Re: Bulk add attributes to all products

I've decided to try doing this by exporting a csv of the zen_products_attributes table. To this csv file I've added the product ID's from the zen_products table, incremented the products_attributes_id field and filled in the rest of the fields according to the attributes info. Next I'm going to import back to the database.

There are no other attributes set up except for a couple I set up in admin to examine the fields so I know I won't be duplicating any ID's.

Are there any problems doing it this way that I might run into?

Also for the purpose of importing the csv file back into the database is it ok to leave the csv export default options as they are which are

options

Fields terminated by ;
Fields enclosed by "
Fields escaped by
Lines terminated by AUTO
Replace NULL by NULL
Remove CRLF characters within fields - box unchecked
Put fields names in the first row - box unchecked

27 Apr 2012, 1:53 PM
#3
buildingblocks avatar

buildingblocks

Totally Zenned

Join Date:
Jun 2008
Posts:
629
Plugin Contributions:
0

Re: Bulk add attributes to all products

csv import worked out fine.