Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default query to determine products with attributes with no default option value

    I want a warning if someone has forgotten to set a default option value on an attribute.
    I'm sure I can do it all in a single query to retrieve that product's id...but brain is refusing to cooperate.

    So, can someone rewrite this to do what I want?

    SELECT pa.products_attributes_id, pa.products_id, pa.options_id, pa.options_values_id, pa.attributes_default
    FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa"

    THANKS!
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

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

    Default Re: query to determine products with attributes with no default option value

    Sure, you might want a refinement since this is going to kick out all TEXT attributes, too:
    Code:
    SELECT DISTINCT pa.products_id, pa.options_id
    FROM products_attributes pa
    GROUP BY pa.products_id, pa.options_id
    HAVING SUM(pa.attributes_default) = 0;

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

    Default Re: query to determine products with attributes with no default option value

    Additional variations:

    Code:
    #all attribs without a default set
    SELECT pa.products_id, pa.options_id
    FROM products_attributes pa
    LEFT JOIN products_options po ON pa.options_id = po.products_options_id
    WHERE products_options_type != 1 AND products_options_type != 4
    GROUP BY pa.products_id, pa.options_id 
    HAVING SUM(pa.attributes_default) = 0
    ORDER BY pa.products_id, pa.options_id, pa.options_values_id;
    
    #all attribs without a default set, AND skip those for which only one option exists (since it is likely auto-set as default anyway)
    SELECT pa.products_id, pa.options_id
    FROM products_attributes pa
    LEFT JOIN products_options po ON pa.options_id = po.products_options_id
    WHERE products_options_type != 1 AND products_options_type != 4
    GROUP BY pa.products_id, pa.options_id 
    HAVING SUM(pa.attributes_default) = 0
     AND COUNT(pa.options_id) > 1
    ORDER BY pa.products_id, pa.options_id, pa.options_values_id;
    
    # all data, for visual inspection
    SELECT pa.products_attributes_id, pa.products_id, p.products_model, pa.options_id, po.products_options_name, pa.options_values_id, pv.products_options_values_name, pa.attributes_default
    FROM products_attributes pa
    LEFT JOIN products_options po ON pa.options_id = po.products_options_id
    LEFT JOIN products_options_values pv ON pa.options_values_id = pv.products_options_values_id
    LEFT JOIN products p ON pa.products_id = p.products_id
    WHERE products_options_type != 1 AND products_options_type != 4
    ORDER BY pa.products_id, pa.options_id, pa.options_values_id;

    Notes: products_options_type 1 is TEXT and 4 is FILE hence the exclusions
    .

    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.

  4. #4
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default Re: query to determine products with attributes with no default option value

    Excellent!

    The background here is that the Dynamic Price Updater does not show any price if the attribute does not have an option preselected/default.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  5. #5
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: query to determine products with attributes with no default option value

    Quote Originally Posted by torvista View Post
    Excellent!

    The background here is that the Dynamic Price Updater does not show any price if the attribute does not have an option preselected/default.
    Is there an example of this condition in the default ZC install with the sample product? I thought the logic included a review of all selected and unselected options to identify a possible minimum price based on the options available from which to select...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: query to determine products with attributes with no default option value

    Quote Originally Posted by torvista View Post
    Excellent!

    The background here is that the Dynamic Price Updater does not show any price if the attribute does not have an option preselected/default.
    Quote Originally Posted by mc12345678 View Post
    Is there an example of this condition in the default ZC install with the sample product? I thought the logic included a review of all selected and unselected options to identify a possible minimum price based on the options available from which to select...
    I'm curious because I just even tried index.php?main_page=product_info&cPath=54_57&products_id=131 and index.php?main_page=product_info&cPath=54_57&products_id=134

    After removing the color option name (which has a dropdown set of attributes that each have a base price) of course this makes the base price of the product 0, but even after I entered a price for the product on the product edit page, no text entered into any of the text fields and the product's base price appeared upon display and then as I entered text, it updated based on the text's pricing scheme. (per letter or per word including total consideration of free letters/words).

    I then also searched for a method that uses radio buttons: index.php?main_page=product_info&cPath=21&products_id=47

    And it has no radio buttons defaulted and does not force any attribute to be selected which allows the product to be added to the cart in that manner. At that point the price of the product is 0 and carries through as 0 until at least a radio button has been selected...

    What I'm also getting at is that not providing a price is similar to saying that the product when placed in the cart does not have a price... So personally I'm trying to better understand so that can possibly address the issue in a solvable manner.

    And to that trying to understand what has been changed from the recent version of DPU to cause this issue where such an additional search/assignment does not appear necessary? I realize its a strong question in absence of response to the earlier question... :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default Re: query to determine products with attributes with no default option value

    >Is there an example of this condition in the default ZC install with the sample product

    Which version of DPU (plugins, your repository/beta, Zen4All...?)....in which Zen Cart...and where should this conversation be continued: Plugin thread or someones Github...:

    Every time I open DPU code it's a Pandora's box so since I understand the various forks of DPU are being mashed into one version to rule them all, I'd prefer to wait to test that, in ZC157, in the relevant repository..
    Thanks.


    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  8. #8
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default Re: query to determine products with attributes with no default option value

    Note also that Zen Cart 1.5.7 has the new function zen_requires_attribute_selection($products_id). The inverse of this would be what you want.
    That Software Guy. My Store: Zen Cart Modifications
    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.

  9. #9
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default Re: query to determine products with attributes with no default option value

    >Zen Cart 1.5.7 has the new function zen_requires_attribute_selection

    Thanks, I didn't know that.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  10. #10
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default Re: query to determine products with attributes with no default option value

    This was done so that items with single valued attributes (such as most downloads) can be added from the listing page.
    That Software Guy. My Store: Zen Cart Modifications
    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.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Copy option value to all products with option name
    By Nick1973 in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 9 Feb 2015, 07:25 PM
  2. Problem with Attributes Controller, Option Name Manager, Option Value Manager
    By Wulf359 in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 27 Jun 2013, 08:54 PM
  3. Attributes - Align Option Name with Option Value?
    By dropbop in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 28 Sep 2009, 07:54 PM
  4. Attributes with one value (option)...
    By Alex Clarke in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 18 Aug 2007, 04:49 PM
  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