Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2010
    Location
    Richmond, Virginia, United States
    Posts
    114
    Plugin Contributions
    0

    Default Set default attribute on all products

    I have over 2000 products.

    Is there an easy way to set the default attribute on all of them to option_values_id 138?

  2. #2
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,173
    Plugin Contributions
    11

    Default Re: Set default attribute on all products

    BACKUP First. Make sure it is a valid backup. Then:

    Code:
    UPDATE products_attributes
    SET attributes_default = 1
    WHERE options_values_id = 138
    This will result in all instances of option_values_id 138 being set to the default.

    NOTE: if you already have some option values other than 138 that are defaults, you will need to remove those first. You can do a sort in PHPmyADmin to find them and fix them before running the update.
    Last edited by dbltoe; 26 May 2021 at 08:51 PM.

  3. #3
    Join Date
    Jul 2012
    Posts
    16,737
    Plugin Contributions
    17

    Default Re: Set default attribute on all products

    Quote Originally Posted by dbltoe View Post
    BACKUP First. Make sure it is a valid backup. Then:

    Code:
    UPDATE products_attributes
    SET attributes_default = 1
    WHERE options_values_id = 138
    This will result in all instances of option_values_id 138 being set to the default.

    NOTE: if you already have some option values other than 138 that are defaults, you will need to remove those first. You can do a sort in PHPmyADmin to find them and fix them before running the update.
    Removal of the others as default while a good idea is not required as a rule. There are factors associated such as if the option name is a checkbox type, then it depends on the final desired result. There are some earlier sub-versions of 1.5.7 where it may be necessary.

    There's also the ability to copy option values available in the products->option values manager at the bottom of the screen.

    Then there is the question of how often is something like this going to be necessary and if you might need to develop some sort of process or use another tool.

    Some other considerations when setting this default is whether the default is selectable for purchase. If not, then need to also set the display only flag as well and would suggest setting the sort order to 0, though that last is not required to prevent adding the attribute as display only and default.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v156 Let customer select default attribute for all products
    By jmsnyder23 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 27 Jul 2019, 07:04 PM
  2. Can a default manufacturer be set for all products that are added to zen cart
    By missesbeehaven in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 10 Apr 2015, 01:57 AM
  3. Any way to set all products to price by attribute?
    By lyingit in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 2 Dec 2011, 12:55 PM
  4. Set up a default attribute?
    By suecalvi in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 28 Nov 2008, 05:46 AM
  5. How to set option value with a set image as default of an attribute?
    By PaulRiedel in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 16 Aug 2007, 04:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR