Results 1 to 8 of 8
  1. #1
    Join Date
    May 2021
    Location
    New York
    Posts
    16
    Plugin Contributions
    0

    Default For the sake of learning, How could I update a products quantity via the SQL Database

    Running the latest versions of everything.

    I know there are plugins like EasyPopulate, but as I said in the title this is for the sake of learning. If I have a products public ID, and wanted to find its ID, and update its Quantity manually in PHPMyadmin, what database would I go to? I see many for products, but cannot figure out where quantity is kept or how the product ID's work. For example, in the product database, a given product will have an ID of 1, and a public ID of whatever I set it to. When I search the public ID in the back end of my site, the product ID it shows me is completely different. Just trying to wrap my head around this.

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,537
    Plugin Contributions
    127

    Default Re: For the sake of learning, How could I update a products quantity via the SQL Data

    Zen Cart has a table called `products` that has a primary key of id.
    So if you wanted to select product 1, you'd use

    SELECT * FROM products WHERE products_id = 1

    The database that your Zen Cart installation uses is shown on the Version screen in your admin.
    See (d) in the large image on this page:
    https://docs.zen-cart.com/user/admin...s/server_info/

    It is not ideal to do things using phpMyAdmin though - you want to learn the Zen Cart admin. You can set a product's quantity on the product edit page:

    https://docs.zen-cart.com/user/products/product_edit/

    Does that make sense?
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #3
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,744
    Plugin Contributions
    22

    Default Re: For the sake of learning, How could I update a products quantity via the SQL Data

    Public ID whatever you set it to? I'm assuming you're mixing the term ID with model number. You can set the model number, but you can not set the product's ID - that's a unique identifier that is automatically assigned by the database with the auto_increment. The ID is completely out of your control.
    If you look at your URL on the product_info page, you'll see ...index.php?main_page=product_info&products_id=1234 - the 1234 is the actual ID. You can NOT search for a product by it's ID in the backend. You can see the product's ID (first column in admin where your products are listed), but you can not search for the ID.
    If the "public ID" is really products_model, then your search might be giving you different results because you're using the same model number for multiple products.

    If you look at the database, you'll see the products_id in multiple tables. Quantity is kept in the products table (zen_products, zc_products or whatever prefix you may have) - field name is products_quantity.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: For the sake of learning, How could I update a products quantity via the SQL Data

    Quote Originally Posted by balihr View Post
    Public ID whatever you set it to? I'm assuming you're mixing the term ID with model number. You can set the model number, but you can not set the product's ID - that's a unique identifier that is automatically assigned by the database with the auto_increment. The ID is completely out of your control.
    If you look at your URL on the product_info page, you'll see ...index.php?main_page=product_info&products_id=1234 - the 1234 is the actual ID. You can NOT search for a product by it's ID in the backend. You can see the product's ID (first column in admin where your products are listed), but you can not search for the ID.
    If the "public ID" is really products_model, then your search might be giving you different results because you're using the same model number for multiple products.

    If you look at the database, you'll see the products_id in multiple tables. Quantity is kept in the products table (zen_products, zc_products or whatever prefix you may have) - field name is products_quantity.
    Ummm, products_id is part of the category product page search, so yes one can search in the admin using the products_id value.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,537
    Plugin Contributions
    127

    Default Re: For the sake of learning, How could I update a products quantity via the SQL Data

    @spanky not sure if your question has been answered - let us know if not.

    If you want to learn more about the database schema for Zen Cart, see the file zc_install/sql/install/mysql_zencart.sql in a fresh download.

    You can also view the schema here:
    https://docs.zen-cart.com/dev/schema/schema_158/
    That Software Guy. My Store: Zen Cart Support
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  6. #6
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,744
    Plugin Contributions
    22

    Default Re: For the sake of learning, How could I update a products quantity via the SQL Data

    Quote Originally Posted by mc12345678 View Post
    Ummm, products_id is part of the category product page search, so yes one can search in the admin using the products_id value.

    Live and learn... Yes, I stand corrected, you CAN search for the products_id (note to self: take 5 secs to test before replying). Thanks, mc!

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

    Default Re: For the sake of learning, How could I update a products quantity via the SQL Data

    Pobody's Nerfect!
    A little help with colors.
    myZenCartHost.com - Zen Cart Certified, PCI Compatible Hosting by JEANDRET
    Free SSL & Domain with semi-annual and longer hosting. Updating 1.5.2 and Up.

  8. #8
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: For the sake of learning, How could I update a products quantity via the SQL Data

    Quote Originally Posted by balihr View Post

    Live and learn... Yes, I stand corrected, you CAN search for the products_id (note to self: take 5 secs to test before replying). Thanks, mc!
    Quote Originally Posted by dbltoe View Post
    Pobody's Nerfect!
    Certainly made me look considering the changes made in 1.5.8. I personally went to the code to see what was expected. Glad you went the other route to confirm. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v139f HTML5 Input Field datetime-local ...just for learning sake?
    By wolfderby in forum General Questions
    Replies: 3
    Last Post: 16 Dec 2016, 03:26 PM
  2. Update all products via database?
    By rschultz in forum General Questions
    Replies: 4
    Last Post: 15 Aug 2011, 07:31 PM
  3. How do I run the stock_attribute.sql via Install SQL Patches in admin
    By vivaraquel in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 9 Apr 2007, 01:55 AM
  4. How to update Quantity for all products?
    By doubletiger in forum General Questions
    Replies: 2
    Last Post: 6 Oct 2006, 10:05 PM

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