Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2010
    Posts
    11
    Plugin Contributions
    0

    Default need a complicated SQL query for setting up a sale

    I am going to be retiring about 1000 products in my store from multiple master categories.

    I have created a new master category for the retirement sale and will be setting it at a % off

    I want to bulk move items into this category based on the following:
    •the product was added over a year ago
    •and it sold 2 or less times

    I don't have any problem finding the products from the products table that I want to retire using a SQL query
    I can also use the same query to set the master category ID to the retirement category
    this makes the price update correctly

    HOWEVER, the products do not show IN the category yet.

    I need to do something to update the products_to_categories where it will insert a new record based on the query above. I am seeing that they will not display in the category until there is a record inserted in this table. But this table ONLY references productID and categoryID.

    I only know enough to run a SQL query in one table.

    How do I write query to insert a record into products_to_categories based on the date/numbered order selection from the products table?

    THANKS

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: need a complicated SQL query for setting up a sale

    Try something like:

    insert ignore into products_to_categories (products_id, categories_id) select products_id, master_categories_id from products where .......;
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: need a complicated SQL query for setting up a sale

    Do you want the Retired Products to *only* be in the Retired Category or still in the current categories?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #4
    Join Date
    Dec 2010
    Posts
    11
    Plugin Contributions
    0

    Default Re: need a complicated SQL query for setting up a sale

    Quote Originally Posted by Ajeh View Post
    Do you want the Retired Products to *only* be in the Retired Category or still in the current categories?
    It doesn't matter, as long as they go into the retiring category AND price correctly. From what I read in order for the salemaker to work, they would have to have the master category set = the retirement category

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: need a complicated SQL query for setting up a sale

    If you just need to change the master_categories_id after the Products have been added to the Retired category, go to the Retired Categories and click C for Copy and then the Multiple Categories Link Manager ...

    At the bottom of the page, you will see:
    Reset ALL Products in the selected Category to use the selected Category as the new Master Categories ID ...
    Example: Resetting Category 22 would set ALL Products in Category 22 to use Category 22 as the Master Category ID Reset the Master Categories ID for All Products in Category:
    This will change all Products in the categories_id that you enter to use that as the master_categories_id ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Dec 2010
    Posts
    11
    Plugin Contributions
    0

    Default Re: need a complicated SQL query for setting up a sale

    that only works if ALL the products are from one master category previously and I am doing that for some designers (manufacturers) whose entire product line is retiring but I am pulling products from multiple designers based on sales performance

  7. #7
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: need a complicated SQL query for setting up a sale

    In your first post I understood that you had already created a new category for all of these expiring products, and that you'd already set their master-categories-id to that category.

    Is that not correct?

    You've said a lot of things that I can't tell whether you're confident that you've done them or if you're just talking all hypothetical but have no idea what you're doing.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v154 Help with a SQL Query for Query Builder
    By lindasdd in forum Managing Customers and Orders
    Replies: 2
    Last Post: 24 Mar 2016, 01:18 PM
  2. v151 Need some help building a looping SQL query to fill an array.
    By Chris Stackhouse in forum General Questions
    Replies: 2
    Last Post: 3 Sep 2015, 08:19 PM
  3. v150 Need an uninstall SQL query
    By coucho in forum All Other Contributions/Addons
    Replies: 8
    Last Post: 12 Dec 2012, 07:16 AM
  4. Need help creating SQL query...
    By DigitalShadow in forum General Questions
    Replies: 2
    Last Post: 22 Jun 2011, 02:05 PM
  5. Need help w/ SQL query in phpMyAdmin
    By audradh in forum General Questions
    Replies: 17
    Last Post: 16 Nov 2009, 01:05 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