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. :)
mc12345678:
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:
('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):
('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:
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:
$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:
$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.
$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, '• Deleted ATTRIBUTES_SBA_DISPLAY_CUSTOMID ' . $msg);
and keep that plus add the following (blue):
$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, '• 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, '• 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:
DELETE IGNORE FROM configuration WHERE `configuration_key` = 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO';