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.

Originally Posted by
mc12345678
@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;

Originally Posted by
mc12345678
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, '• 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, '• 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:
Code:
DELETE IGNORE FROM configuration WHERE `configuration_key` = 'SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO';
Bookmarks