Page 262 of 359 FirstFirst ... 162212252260261262263264272312 ... LastLast
Results 2,611 to 2,620 of 3589
  1. #2611
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    Quote Originally Posted by frank18 View Post
    I am in the process of upgrading a site from ZC 1.3.9d to 1.5.5a. Because upgrades have not been done progressively (amongst other no,no,no's), I am now faced with making SBA workable on the updated site.

    Downloaded the latest version of SBA combined from Github.

    Question: How does the new installer supposed to be handled? I just see the file admin/stock_by_attr_install.php to effect this.

    Am I supposed to run the file stock_by_attr_install.php manually or what is the intention (can't find any updated documentation for this version on Github)?

    TIA / Frank
    There has been no change in the intention of running the install file from any previous documentation. It is not installed or updated without accessing that file and choosing to upgrade/install. The sba variant table if it exists will remain and if it requires modifications (none made since potteryhouse's version of 1.5.3) then those will be applied. Otherwise the general instructions provided by the documentation for sba at pottryhouse's github still apply. There just is more functionality available now.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #2612
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    Quote Originally Posted by mc12345678 View Post
    There has been no change in the intention of running the install file from any previous documentation. It is not installed or updated without accessing that file and choosing to upgrade/install. The sba variant table if it exists will remain and if it requires modifications (none made since potteryhouse's version of 1.5.3) then those will be applied. Otherwise the general instructions provided by the documentation for sba at pottryhouse's github still apply. There just is more functionality available now.
    Thanks mc - so simply referring back to the to the latest of pottryhouse will do the trick, much appreciated.

  3. #2613
    Join Date
    May 2006
    Location
    Montana
    Posts
    291
    Plugin Contributions
    20

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    Does the potteryhouse version get the "out of stock" attributes not to show up in the dropdown - like the older version of SBA used with 1.5.0?

    For some reason the combo version still shows all the option values - marked "out of stock", but would prefer it if any option value is not in stock that it just doesn't show up. Am I missing a configuration somewhere?

    Quote Originally Posted by mc12345678 View Post
    There has been no change in the intention of running the install file from any previous documentation. It is not installed or updated without accessing that file and choosing to upgrade/install. The sba variant table if it exists will remain and if it requires modifications (none made since potteryhouse's version of 1.5.3) then those will be applied. Otherwise the general instructions provided by the documentation for sba at pottryhouse's github still apply. There just is more functionality available now.

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

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    Quote Originally Posted by stellarweb View Post
    Does the potteryhouse version get the "out of stock" attributes not to show up in the dropdown - like the older version of SBA used with 1.5.0?

    For some reason the combo version still shows all the option values - marked "out of stock", but would prefer it if any option value is not in stock that it just doesn't show up. Am I missing a configuration somewhere?
    I have to go back and 1) look at the current code and 2) look at changes that were made. For some reason I recall a constant being used to do that, but it was based on the store as a whole and I thought I didn't see the relationship. I say this because in navigating the demo site I saw that product were desired to remain displayed even if the product was out-of-stock. Because of that, SBA would require a separate setting than what the store has. Ie. Store allows out-of-stock product to be displayed, while SBA product option listings would hide the display of out-of-stock attribute options.

    Such capability already exists when using dynamic dropdowns for the applicable quantity of option names (attributes). Thing is I haven't done much if anything to make sure that the multiple attributes options settings (to be used for product having a single option name) is fully functional. I saw problems with it early on but since potteryhouse had a functional version didn't see the need to modify that code especially if someone already had it reworked and transferred their version to their new/upgraded site.

    In my tests yesterday (not 100% exhaustive) I came across the same issue you described that the attribute options continued to display even when the attribute option was out-of-stock. Now, that said and because the sql query posted here was run instead of the install, it appears that some settings are not in place/set to prevent selection of an out-of-stock attribute. What was seen was that an item that is out-of-stock could be selected, and an attempt made to add to the cart which would guide the individual to an empty cart without a notification (issue that existed in ZC 1.5.4)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #2615
    Join Date
    May 2006
    Location
    Montana
    Posts
    291
    Plugin Contributions
    20

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    On the 1.5.0 site that I am upgrading... the "not in stock" attributes don't show up - and if there is just one attribute left that has a stock amount, the item shows up as a radio button instead of a dropdown.

    I definitely need this capability, because my client is NOT going to be happy seeing the "out of stock" ones displayed. Any suggestions on what I should do from here?

    Thanks Chad for your assistance!

    Quote Originally Posted by mc12345678 View Post
    I have to go back and 1) look at the current code and 2) look at changes that were made. For some reason I recall a constant being used to do that, but it was based on the store as a whole and I thought I didn't see the relationship. I say this because in navigating the demo site I saw that product were desired to remain displayed even if the product was out-of-stock. Because of that, SBA would require a separate setting than what the store has. Ie. Store allows out-of-stock product to be displayed, while SBA product option listings would hide the display of out-of-stock attribute options.

    Such capability already exists when using dynamic dropdowns for the applicable quantity of option names (attributes). Thing is I haven't done much if anything to make sure that the multiple attributes options settings (to be used for product having a single option name) is fully functional. I saw problems with it early on but since potteryhouse had a functional version didn't see the need to modify that code especially if someone already had it reworked and transferred their version to their new/upgraded site.

    In my tests yesterday (not 100% exhaustive) I came across the same issue you described that the attribute options continued to display even when the attribute option was out-of-stock. Now, that said and because the sql query posted here was run instead of the install, it appears that some settings are not in place/set to prevent selection of an out-of-stock attribute. What was seen was that an item that is out-of-stock could be selected, and an attempt made to add to the cart which would guide the individual to an empty cart without a notification (issue that existed in ZC 1.5.4)

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

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    @stellarweb:

    In admin/stock_by_attr_install.php

    Find Lines 741-743:
    Code:
          ('SBA Display Attributes Images', 'SBA_SHOW_IMAGE_ON_PRODUCT_INFO', '1',  
        'Allow swap of the attribute image with the main image or prevent the display of the Attribute Image (and allow swap) on the product information page:<br /><br /> Default: 1 (Swap and display)<br />0 - No swap, display image ZC default<br />1 - Swap and display attr img<br />2 - Swap, but hide attribute image', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\', \'2\'),'),";
    And modify to below (changing the end of the last line to remove the "; in red) and adding below it (in blue):

    Code:
          ('SBA Display Attributes Images', 'SBA_SHOW_IMAGE_ON_PRODUCT_INFO', '1',  
        'Allow swap of the attribute image with the main image or prevent the display of the Attribute Image (and allow swap) on the product information page:<br /><br /> Default: 1 (Swap and display)<br />0 - No swap, display image ZC default<br />1 - Swap and display attr img<br />2 - Swap, but hide attribute image', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\', \'2\'),'),
          ('SBA Display Non-DD Out-of-Stock Attributes', 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO', '1',  
        'Allow display of attributes that are out-of-stock and are not managed by Dynamic Dropdowns.<br /><br /> Default: 1 (Show out-of-stock attributes)<br />0 - Hide out-of-stock attributes<br />1 - Show out-of-stock attributes', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\'),'),";
    
    To add/install the above without going through the install process (not recommended to go this way unless the install process has been followed as included in the most recent version):

    Code:
    SELECT @sortorder := c.sort_order 
    FROM configuration c WHERE c.configuration_group_id = 9 AND configuration_key = 'STOCK_SET_SBA_SEARCHBOX';
    
    INSERT INTO `configuration` (configuration_title, configuration_key, configuration_value,  
    	       configuration_description, configuration_group_id, sort_order,  
    	       date_added, use_function, set_function)  
    	       VALUES  
          ('SBA Display Non-DD Out-of-Stock Attributes', 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO', '1',  
        'Allow display of attributes that are out-of-stock and are not managed by Dynamic Dropdowns.<br /><br /> Default: 1 (Show out-of-stock attributes)<br />0 - Hide out-of-stock attributes<br />1 - Show out-of-stock attributes', 
          9, @sortorder,now(),null,'zen_cfg_select_option(array(\'0\', \'1\'),');
    If the above query doesn't add the new option, then more than likely the configuration_key in the first query doesn't exist which is a key in the configuration of the plugin that is installed when running the install process. Which would be further more reason to go back to incorporate the above code (if not already updated in the install package) and run the installation.

    Then to take advantage of the above setting, modify the store front code as below:

    In includes/classes/observers/class.products_with_attributes_stock.php

    beginning at line 326 find:
    Code:
           $sql = "select distinct pov.products_options_values_id, 
                            pov.products_options_values_name, 
                            pa.*, p.products_quantity,  
                          " . (($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1))? " pas.stock_id as pasid, pas.quantity as pasqty, pas.sort,  pas.customid, pas.title, pas.product_attribute_combo, pas.stock_attributes, " : "") . " pas.products_id  
     
                    from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
                    left join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on (pa.options_values_id = pov.products_options_values_id) 
                    left join " . TABLE_PRODUCTS . " p on (pa.products_id = p.products_id) 
                     
                    left join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pas on  
                    (p.products_id = pas.products_id and FIND_IN_SET(pa.products_attributes_id, pas.stock_attributes) > 0 ) 
                where pa.products_id = :products_id: 
                and       pa.options_id = :options_id: 
                and       pov.language_id = :languages_id: " . 
                  $order_by;
    Change to:
    Code:
           $sql = "select distinct pov.products_options_values_id, 
                            pov.products_options_values_name, 
                            pa.*, p.products_quantity,  
                          " . (($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1))? " pas.stock_id as pasid, pas.quantity as pasqty, pas.sort,  pas.customid, pas.title, pas.product_attribute_combo, pas.stock_attributes, " : "") . " pas.products_id  
     
                    from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
                    left join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on (pa.options_values_id = pov.products_options_values_id) 
                    left join " . TABLE_PRODUCTS . " p on (pa.products_id = p.products_id) 
                     
                    left join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pas on  
                    (p.products_id = pas.products_id and FIND_IN_SET(pa.products_attributes_id, pas.stock_attributes) > 0 ) 
                where pa.products_id = :products_id: 
                and       pa.options_id = :options_id: 
                and       pov.language_id = :languages_id: " . 
                ((($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1)) && defined('SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO') && SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO == '0' && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS !=1 && PRODINFO_ATTRIBUTE_DYNAMIC_STATUS !=3)) ? " AND (pas.quantity > '0' OR (pas.quantity IS NULL AND pa.attributes_display_only = '1')) ": "" ) . 
     
                  $order_by;
    Reasoning or explanation of the added SQL statement portion.

    The test logic is,
    - basically if querying data to apply to the Option name type of SBA Select List (Dropdown) Basic (single effective option name) and single option name product are not controlled by dynamic dropdowns then want to show only items that have a quantity greater than 0 or if the attribute (option value for this product) is marked as display only. By default SBA doesn't count display only attributes as having stock therefore, the query result of the tables being "merged" is NULL so test for that against all of the other factors as well.

    This particular statement may need to be modified further down the road as someone points out a flaw with it, but for now it works for the following condition:
    A product that has a single attribute with multiple option values,
    one of the option values being display only,
    variants are populated in the SBA table for each of the assigned attributes except for one of the stockable attributes (and not for the display only attribute),
    one of the variants of the product has a 0 quantity the rest have a quantity greater than 0.

    The variant with 0 quantity is hidden as applicable to the admin setting that is added to the configuration->Stock menu. With the newly added SBA option set to hide out-of-stock product, the deleted variant does not appear in the dropdown, though prior to this revision, the non-variant attribute (one that was deleted from the SBA table) would appear in the list, but would not be successfully added to the cart, so that may need to still be addressed somewhat separately. The above SQL pretty much takes care of that in a round about way and the option may be applied, but for now was trying to address the issue desired to be resolved. I can't say that I searched high and low for the historical background, but I also seem to recall that with moving code out of the attributes file that there perhaps was an option that didn't follow because of having to carry over information from one location to another, but this did the trick. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #2617
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    Quote Originally Posted by stellarweb View Post
    On the 1.5.0 site that I am upgrading... the "not in stock" attributes don't show up - and if there is just one attribute left that has a stock amount, the item shows up as a radio button instead of a dropdown.

    I definitely need this capability, because my client is NOT going to be happy seeing the "out of stock" ones displayed. Any suggestions on what I should do from here?

    Thanks Chad for your assistance!
    Besides the suggested modification provided above (which will allow acting as described as desired), might look into if the old store has an updated includes/classes/pad_multiple_dropdowns.php file (updated is something of a relative term, but applies to the file being different than what is provided in this package).

    What was provided in this package is nearly the exact same thing that has been available for years as a separate plugin but is currently merged to an extent into this plugin to try to maintain some semblance of consistency and continue to provide a means to keep an existing front end but improved backend of the program.
    Last edited by mc12345678; 22 Aug 2016 at 04:22 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    Forgot to include applicable deletion code. The deletion code should be applied (because of line numbers) after the insertion code has been incorporated when working with the file directly. Plan is to push all of this information into a single commit to github which is not possible in my current computing environment.

    Quote Originally Posted by mc12345678 View Post
    @stellarweb:
    In admin/stock_by_attr_install.php

    Find Lines 741-743:
    Code:
          ('SBA Display Attributes Images', 'SBA_SHOW_IMAGE_ON_PRODUCT_INFO', '1',  
        'Allow swap of the attribute image with the main image or prevent the display of the Attribute Image (and allow swap) on the product information page:<br /><br /> Default: 1 (Swap and display)<br />0 - No swap, display image ZC default<br />1 - Swap and display attr img<br />2 - Swap, but hide attribute image', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\', \'2\'),'),";
    And modify to below (changing the end of the last line to remove the "; in red) and adding below it (in blue):

    Code:
          ('SBA Display Attributes Images', 'SBA_SHOW_IMAGE_ON_PRODUCT_INFO', '1',  
        'Allow swap of the attribute image with the main image or prevent the display of the Attribute Image (and allow swap) on the product information page:<br /><br /> Default: 1 (Swap and display)<br />0 - No swap, display image ZC default<br />1 - Swap and display attr img<br />2 - Swap, but hide attribute image', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\', \'2\'),'),
          ('SBA Display Non-DD Out-of-Stock Attributes', 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO', '1',  
        'Allow display of attributes that are out-of-stock and are not managed by Dynamic Dropdowns.<br /><br /> Default: 1 (Show out-of-stock attributes)<br />0 - Hide out-of-stock attributes<br />1 - Show out-of-stock attributes', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\'),'),";
    
    To add/install the above without going through the install process (not recommended to go this way unless the install process has been followed as included in the most recent version) [modified to advise how/where to apply the sql] after logging into the admin area goto tools->Install SQL Patches and paste the following:

    Code:
    SELECT @sortorder := c.sort_order 
    FROM configuration c WHERE c.configuration_group_id = 9 AND configuration_key = 'STOCK_SET_SBA_SEARCHBOX';
    
    INSERT INTO `configuration` (configuration_title, configuration_key, configuration_value,  
               configuration_description, configuration_group_id, sort_order,  
               date_added, use_function, set_function)  
               VALUES  
          ('SBA Display Non-DD Out-of-Stock Attributes', 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO', '1',  
        'Allow display of attributes that are out-of-stock and are not managed by Dynamic Dropdowns.<br /><br /> Default: 1 (Show out-of-stock attributes)<br />0 - Hide out-of-stock attributes<br />1 - Show out-of-stock attributes', 
          9, @sortorder,now(),null,'zen_cfg_select_option(array(\'0\', \'1\'),');
    If the above query doesn't add the new option, then more than likely the configuration_key in the first query doesn't exist which is a key in the configuration of the plugin that is installed when running the install process. Which would be further more reason to go back to incorporate the above code (if not already updated in the install package) and run the installation.

    Then to take advantage of the above setting, modify the store front code as below:

    In includes/classes/observers/class.products_with_attributes_stock.php

    beginning at line 326 find:
    Code:
           $sql = "select distinct pov.products_options_values_id, 
                            pov.products_options_values_name, 
                            pa.*, p.products_quantity,  
                          " . (($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1))? " pas.stock_id as pasid, pas.quantity as pasqty, pas.sort,  pas.customid, pas.title, pas.product_attribute_combo, pas.stock_attributes, " : "") . " pas.products_id  
     
                    from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
                    left join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on (pa.options_values_id = pov.products_options_values_id) 
                    left join " . TABLE_PRODUCTS . " p on (pa.products_id = p.products_id) 
                     
                    left join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pas on  
                    (p.products_id = pas.products_id and FIND_IN_SET(pa.products_attributes_id, pas.stock_attributes) > 0 ) 
                where pa.products_id = :products_id: 
                and       pa.options_id = :options_id: 
                and       pov.language_id = :languages_id: " . 
                  $order_by;
    Change to:
    Code:
           $sql = "select distinct pov.products_options_values_id, 
                            pov.products_options_values_name, 
                            pa.*, p.products_quantity,  
                          " . (($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1))? " pas.stock_id as pasid, pas.quantity as pasqty, pas.sort,  pas.customid, pas.title, pas.product_attribute_combo, pas.stock_attributes, " : "") . " pas.products_id  
     
                    from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
                    left join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on (pa.options_values_id = pov.products_options_values_id) 
                    left join " . TABLE_PRODUCTS . " p on (pa.products_id = p.products_id) 
                     
                    left join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pas on  
                    (p.products_id = pas.products_id and FIND_IN_SET(pa.products_attributes_id, pas.stock_attributes) > 0 ) 
                where pa.products_id = :products_id: 
                and       pa.options_id = :options_id: 
                and       pov.language_id = :languages_id: " . 
                ((($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1)) && defined('SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO') && SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO == '0' && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS !=1 && PRODINFO_ATTRIBUTE_DYNAMIC_STATUS !=3)) ? " AND (pas.quantity > '0' OR (pas.quantity IS NULL AND pa.attributes_display_only = '1')) ": "" ) . 
     
                  $order_by;
    Quote Originally Posted by mc12345678 View Post
    Reasoning or explanation of the added SQL statement portion.

    The test logic is,
    - basically if querying data to apply to the Option name type of SBA Select List (Dropdown) Basic (single effective option name) and single option name product are not controlled by dynamic dropdowns then want to show only items that have a quantity greater than 0 or if the attribute (option value for this product) is marked as display only. By default SBA doesn't count display only attributes as having stock therefore, the query result of the tables being "merged" is NULL so test for that against all of the other factors as well.

    This particular statement may need to be modified further down the road as someone points out a flaw with it, but for now it works for the following condition:
    A product that has a single attribute with multiple option values,
    one of the option values being display only,
    variants are populated in the SBA table for each of the assigned attributes except for one of the stockable attributes (and not for the display only attribute),
    one of the variants of the product has a 0 quantity the rest have a quantity greater than 0.

    The variant with 0 quantity is hidden as applicable to the admin setting that is added to the configuration->Stock menu. With the newly added SBA option set to hide out-of-stock product, the deleted variant does not appear in the dropdown, though prior to this revision, the non-variant attribute (one that was deleted from the SBA table) would appear in the list, but would not be successfully added to the cart, so that may need to still be addressed somewhat separately. The above SQL pretty much takes care of that in a round about way and the option may be applied, but for now was trying to address the issue desired to be resolved. I can't say that I searched high and low for the historical background, but I also seem to recall that with moving code out of the attributes file that there perhaps was an option that didn't follow because of having to carry over information from one location to another, but this did the trick. :)
    The deletion code is to locate in:
    admin/stock_by_attr_install.php at or around lines 324-330.
    Code:
         
      $sql = "DELETE IGNORE FROM `".TABLE_CONFIGURATION."` WHERE `configuration_key` = 'ATTRIBUTES_SBA_DISPLAY_CUSTOMID'"; 
      $db->Execute($sql); 
      if($db->error){         
        $msg = ' Error Message: ' . $db->error; 
      } 
      array_push($resultMmessage, '&bull; Deleted ATTRIBUTES_SBA_DISPLAY_CUSTOMID  ' . $msg);
    and keep that plus add the following (blue):
    Code:
         
      $sql = "DELETE IGNORE FROM `".TABLE_CONFIGURATION."` WHERE `configuration_key` = 'ATTRIBUTES_SBA_DISPLAY_CUSTOMID'"; 
      $db->Execute($sql); 
      if($db->error){         
        $msg = ' Error Message: ' . $db->error; 
      } 
      array_push($resultMmessage, '&bull; Deleted ATTRIBUTES_SBA_DISPLAY_CUSTOMID  ' . $msg); 
         
      $sql = "DELETE IGNORE FROM `".TABLE_CONFIGURATION."` WHERE `configuration_key` = 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO'"; 
      $db->Execute($sql); 
      if($db->error){         
        $msg = ' Error Message: ' . $db->error; 
      } 
      array_push($resultMmessage, '&bull; Deleted SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO  ' . $msg); 
    
    To delete the key directly (ie if attempting this in a test environment where the install sql has been entered in the code and then the plugin has been uninstalled or attempted to be installed again without having the above removal code or basically if receive a myDebug error that indicates that the key 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO' already exists), then from within the tools->Install SQL Patches area enter the following:
    Code:
    DELETE IGNORE FROM configuration WHERE `configuration_key` = 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO';
    Last edited by mc12345678; 22 Aug 2016 at 05:00 PM. Reason: To be able to show that a portion of OP was modified for clarity of applying SQL
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #2619
    Join Date
    May 2006
    Location
    Montana
    Posts
    291
    Plugin Contributions
    20

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    Your recommended changes did the trick!!! WHOO HOO!! Thank you so much!!

  10. #2620
    Join Date
    Jul 2012
    Posts
    16,798
    Plugin Contributions
    17

    Default Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

    FYI, thinking about it a little more, READ ONLY attributes (Option Name having the Read Only type) are or can be negatively impacted by the above code and herein is where things really start getting complex (if it hasn't already) and one reason why dynamic dropdowns doesn't yet offer read only attributes. Also in review, it appears that GRID related product may be affected as well, so I've made the below modification to the new query that is found in the includes/classes/observers/class.products_with_attributes_stock.php file.

    Trying to add the maximum usage of this "feature" with minimal impact on other potential uses of SBA and without forcing too many hoops to be jumped through (ie. readonly option values being marked as display only which is kind of unnecessary since they are already for display, but it does appear that some have used it for other things based on code remnants and options). Funny thing about it though, is that so many have striven to be able to show out-of-stock attributes and here's a case where it is desired to not show them. :)


    Quote Originally Posted by mc12345678 View Post
    Forgot to include applicable deletion code. The deletion code should be applied (because of line numbers) after the insertion code has been incorporated when working with the file directly. Plan is to push all of this information into a single commit to github which is not possible in my current computing environment.
    In admin/stock_by_attr_install.php

    Find Lines 741-743:
    Code:
          ('SBA Display Attributes Images', 'SBA_SHOW_IMAGE_ON_PRODUCT_INFO', '1',  
        'Allow swap of the attribute image with the main image or prevent the display of the Attribute Image (and allow swap) on the product information page:<br /><br /> Default: 1 (Swap and display)<br />0 - No swap, display image ZC default<br />1 - Swap and display attr img<br />2 - Swap, but hide attribute image', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\', \'2\'),'),";
    And modify to below (changing the end of the last line to remove the "; in red) and adding below it (in blue):

    Code:
          ('SBA Display Attributes Images', 'SBA_SHOW_IMAGE_ON_PRODUCT_INFO', '1',  
        'Allow swap of the attribute image with the main image or prevent the display of the Attribute Image (and allow swap) on the product information page:<br /><br /> Default: 1 (Swap and display)<br />0 - No swap, display image ZC default<br />1 - Swap and display attr img<br />2 - Swap, but hide attribute image', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\', \'2\'),'),
          ('SBA Display Non-DD Out-of-Stock Attributes', 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO', '1',  
        'Allow display of attributes that are out-of-stock and are not managed by Dynamic Dropdowns.<br /><br /> Default: 1 (Show out-of-stock attributes)<br />0 - Hide out-of-stock attributes<br />1 - Show out-of-stock attributes', 
          9,".$result.",now(),null,'zen_cfg_select_option(array(\'0\', \'1\'),'),";
    
    To add/install the above without going through the install process (not recommended to go this way unless the install process has been followed as included in the most recent version) [modified to advise how/where to apply the sql] after logging into the admin area goto tools->Install SQL Patches and paste the following:

    Code:
    SELECT @sortorder := c.sort_order 
    FROM configuration c WHERE c.configuration_group_id = 9 AND configuration_key = 'STOCK_SET_SBA_SEARCHBOX';
    
    INSERT INTO `configuration` (configuration_title, configuration_key, configuration_value,  
               configuration_description, configuration_group_id, sort_order,  
               date_added, use_function, set_function)  
               VALUES  
          ('SBA Display Non-DD Out-of-Stock Attributes', 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO', '1',  
        'Allow display of attributes that are out-of-stock and are not managed by Dynamic Dropdowns.<br /><br /> Default: 1 (Show out-of-stock attributes)<br />0 - Hide out-of-stock attributes<br />1 - Show out-of-stock attributes', 
          9, @sortorder,now(),null,'zen_cfg_select_option(array(\'0\', \'1\'),');
    If the above query doesn't add the new option, then more than likely the configuration_key in the first query doesn't exist which is a key in the configuration of the plugin that is installed when running the install process. Which would be further more reason to go back to incorporate the above code (if not already updated in the install package) and run the installation.

    Then to take advantage of the above setting, modify the store front code as below:

    In includes/classes/observers/class.products_with_attributes_stock.php

    beginning at line 326 find:
    Code:
           $sql = "select distinct pov.products_options_values_id, 
                            pov.products_options_values_name, 
                            pa.*, p.products_quantity,  
                          " . (($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1))? " pas.stock_id as pasid, pas.quantity as pasqty, pas.sort,  pas.customid, pas.title, pas.product_attribute_combo, pas.stock_attributes, " : "") . " pas.products_id  
     
                    from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
                    left join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on (pa.options_values_id = pov.products_options_values_id) 
                    left join " . TABLE_PRODUCTS . " p on (pa.products_id = p.products_id) 
                     
                    left join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pas on  
                    (p.products_id = pas.products_id and FIND_IN_SET(pa.products_attributes_id, pas.stock_attributes) > 0 ) 
                where pa.products_id = :products_id: 
                and       pa.options_id = :options_id: 
                and       pov.language_id = :languages_id: " . 
                  $order_by;
    Change to:
    Code:
           $sql = "select distinct pov.products_options_values_id, 
                            pov.products_options_values_name, 
                            pa.*, p.products_quantity,  
                          " . (($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1))? " pas.stock_id as pasid, pas.quantity as pasqty, pas.sort,  pas.customid, pas.title, pas.product_attribute_combo, pas.stock_attributes, " : "") . " pas.products_id  
     
                    from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
                    left join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov on (pa.options_values_id = pov.products_options_values_id) 
                    left join " . TABLE_PRODUCTS . " p on (pa.products_id = p.products_id) 
                     
                    left join " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pas on  
                    (p.products_id = pas.products_id and FIND_IN_SET(pa.products_attributes_id, pas.stock_attributes) > 0 ) 
                where pa.products_id = :products_id: 
                and       pa.options_id = :options_id: 
                and       pov.language_id = :languages_id: " . 
                ((($this->_products_options_names_count <= 1 || ($process_this == true && isset($noread) && $noread->fields['total'] == 1)) && defined('SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO') && SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO == '0' && (PRODINFO_ATTRIBUTE_DYNAMIC_STATUS !=1 && PRODINFO_ATTRIBUTE_DYNAMIC_STATUS !=3) && $products_options_name->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_READONLY && (defined('PRODUCTS_OPTIONS_TYPE_GRID') ? $products_options_name->fields['products_options_type'] != PRODUCTS_OPTIONS_TYPE_GRID : true)) ? " AND (pas.quantity > '0' OR (pas.quantity IS NULL AND pa.attributes_display_only = '1')) ": "" ) . 
     
                  $order_by;

    The deletion code is to locate in:
    admin/stock_by_attr_install.php at or around lines 324-330.
    Code:
         
      $sql = "DELETE IGNORE FROM `".TABLE_CONFIGURATION."` WHERE `configuration_key` = 'ATTRIBUTES_SBA_DISPLAY_CUSTOMID'"; 
      $db->Execute($sql); 
      if($db->error){         
        $msg = ' Error Message: ' . $db->error; 
      } 
      array_push($resultMmessage, '&bull; Deleted ATTRIBUTES_SBA_DISPLAY_CUSTOMID  ' . $msg);
    and keep that plus add the following (blue):
    Code:
         
      $sql = "DELETE IGNORE FROM `".TABLE_CONFIGURATION."` WHERE `configuration_key` = 'ATTRIBUTES_SBA_DISPLAY_CUSTOMID'"; 
      $db->Execute($sql); 
      if($db->error){         
        $msg = ' Error Message: ' . $db->error; 
      } 
      array_push($resultMmessage, '&bull; Deleted ATTRIBUTES_SBA_DISPLAY_CUSTOMID  ' . $msg); 
         
      $sql = "DELETE IGNORE FROM `".TABLE_CONFIGURATION."` WHERE `configuration_key` = 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO'"; 
      $db->Execute($sql); 
      if($db->error){         
        $msg = ' Error Message: ' . $db->error; 
      } 
      array_push($resultMmessage, '&bull; Deleted SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO  ' . $msg); 
    
    To delete the key directly (ie if attempting this in a test environment where the install sql has been entered in the code and then the plugin has been uninstalled or attempted to be installed again without having the above removal code or basically if receive a myDebug error that indicates that the key 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO' already exists), then from within the tools->Install SQL Patches area enter the following:
    Code:
    DELETE IGNORE FROM configuration WHERE `configuration_key` = 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO';
    Last edited by mc12345678; 22 Aug 2016 at 05:57 PM. Reason: Edit was to ensure last code text was "quoted"
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Problems with addon: Dynamic Drop Downs for Stock By Attribute
    By Dunk in forum All Other Contributions/Addons
    Replies: 56
    Last Post: 30 Apr 2014, 07:55 PM
  2. MySQL Problem with Product with Attribute Stock addon
    By rtwingfield in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 20 Sep 2011, 03:35 PM
  3. Hide Zero Quantity Attributes with attribute-stock addon
    By leevil123 in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 11 Feb 2010, 05:06 PM
  4. Replies: 4
    Last Post: 22 Jan 2010, 10:43 PM
  5. Price Products in the grid by 'Stock by Attribute' addon?
    By Salixia in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 27 Oct 2009, 06:03 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