Results 1 to 10 of 1125

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default

    Quote Originally Posted by DivaVocals View Post
    I don't have a SQL script handy that does this, and I would need help myself to construct one (seems there would be a bit of complexity in this kind of update script that is beyond my basic SQL knowledge) but to answer your question generally, yes, you could construct some SQL to do this update..

    Only if you update the variant quantities via a direct upload..
    Does anyone know the query that gets sent to the database when clicking the sync qtys button? If I knew this I should imagine I could simply add this to the end of my update qty syntax???
    Posted via Mobile Device

  2. #2
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,021
    Plugin Contributions
    32

    Default Re: Stocks by attributes

    Quote Originally Posted by philip937 View Post
    Does anyone know the query that gets sent to the database when clicking the sync qtys button? If I knew this I should imagine I could simply add this to the end of my update qty syntax???
    Posted via Mobile Device
    Don't know why I didn't think of that.. I personally don't know the query off the top of my head, but if you dig through the files for this add-on, it should be easy to locate it yourself..

  3. #3
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Stocks by attributes

    In the products_with_attributes_stock class you'll find this short function
    Code:
    function update_parent_products_stock($products_id)
    {
      global $db;
      $query = 'select sum(quantity) as quantity from '.TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK.' where products_id = "'.(int)$products_id.'"';
      $quantity = $db->Execute($query);
      $query = 'update '.TABLE_PRODUCTS.' set  products_quantity="'.$quantity->fields['quantity'].'" where products_id="'.(int)$products_id.'"';
      $db->Execute($query);
    }
    It first collects the summed total for a product's attribute variants and then applies it to the product table for that product.

    To avoid the php and apply it to all products, you would probably want to create a database view or a temporary table based on the first query and then apply the resulting rows in that to all matching rows in the product table.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

 

 

Similar Threads

  1. v139h Stocks of certain products disappearing automatically
    By Lowwi in forum General Questions
    Replies: 4
    Last Post: 11 Aug 2015, 09:09 PM
  2. Installing Stocks by Attribute
    By dragon03kf in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 26 Oct 2008, 07:42 PM
  3. Stocks by attributes
    By hcd888 in forum General Questions
    Replies: 1
    Last Post: 12 May 2008, 08:52 AM
  4. Multiple stocks per product
    By jaycode in forum General Questions
    Replies: 4
    Last Post: 5 Aug 2007, 11:55 AM
  5. Products with attribute stocks
    By Svanis in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 5 Jul 2006, 03:19 AM

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