Results 1 to 5 of 5
  1. #1
    Join Date
    May 2016
    Location
    Ohio
    Posts
    410
    Plugin Contributions
    0

    Default Add SQL Query Executor

    Is there an SQL command to add an attribute to all items in the store in bulk?

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,614
    Plugin Contributions
    88

    Default Re: Add SQL Query Executor

    Is this a brand-new attribute that isn't currently associated with any product?

  3. #3
    Join Date
    May 2016
    Location
    Ohio
    Posts
    410
    Plugin Contributions
    0

    Default Re: Add SQL Query Executor

    Correct

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,614
    Plugin Contributions
    88

    Default Re: Add SQL Query Executor

    It's going to be easier to create a one-time-run PHP script. Take this template, changing 33 to the options_id and 44 to the options_values_id of the to-be-inserted attribute and saving the script in the root directory of your site (let's pretend it's add_attributes.php):

    Code:
    <?php
    require 'includes/application_top.php';
    
    $products = $db->Execute('SELECT products_id FROM ' . TABLE_PRODUCTS);
    $sql_template =
        'INSERT INTO ' . TABLE_PRODUCTS_ATTRIBUTES . '
            (products_id, options_id, options_values_id)
         VALUES
            (%u, 33, 44)';
    foreach ($products as $next_product) {
        $sql = sprintf($sql_template, (int)$next_product['products_id']);
        $db->Execute($sql);
    }
    
    require DIR_WS_INCLUDES . 'application_bottom.php';
    Then on your browser's command line, enter https://mysite.com/add_attributes.php ... after you've made a database backup!

    Once run, make sure that the add_attributes.php file is deleted from the site.

  5. #5
    Join Date
    May 2016
    Location
    Ohio
    Posts
    410
    Plugin Contributions
    0

    Default Re: Add SQL Query Executor

    Oh! Interesting! Thankyou!

 

 

Similar Threads

  1. v150 SQL Query Executor
    By dochsa in forum General Questions
    Replies: 3
    Last Post: 7 Sep 2012, 11:14 AM
  2. SQL Query Executor
    By tomreitz in forum General Questions
    Replies: 6
    Last Post: 30 Nov 2009, 09:55 PM
  3. SQL Query Executor
    By pukman in forum General Questions
    Replies: 1
    Last Post: 8 Jul 2009, 11:43 AM
  4. SQL Query Executor
    By MeltDown in forum General Questions
    Replies: 2
    Last Post: 15 Jul 2006, 05:41 PM

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