Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Badarac,
Thank. You for this valuable feedback.
The logged error is because the routne is run where no attrbutes are present to fullfill the internal code. In an effort to remove SBA from modfying so many core files (unfortunately the includes/classes/orders.php file still needs a small modifcation to take advantage of data for future use) it would appear that the low-stock check (and possibly other such sections) needs to verify that the involved product is in fact tracked by SBA. There is a similar check elsewhere in the observer class. Will take a look to see if can suggest applicable code.
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
@badarac, et al.
In includes/classes/observers/class.product_with_attributes_stock.php
Find the function:
Replace with the following:
Code:
/*
* Function that is activated when NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_END is encountered as a notifier.
*/
// Line 776
function updateNotifyOrderProcessingStockDecrementEnd(&$callingClass, $notifier, $paramsArray) {
if (zen_product_is_sba($this->_productI['id'])) { // Only take SBA action on SBA tracked product mc12345678 12-18-2015
//Need to modify the email that is going out regarding low-stock.
//paramsArray is $i at time of development.
if ($callingClass->email_low_stock == '' && $callingClass->doStockDecrement && $this->_stock_values->RecordCount() > 0 && $this->_attribute_stock_left <= STOCK_REORDER_LEVEL) {
// kuroi: trigger and details for attribute low stock email
$callingClass->email_low_stock .= 'ID# ' . zen_get_prid($this->_productI['id']) . ', model# ' . $this->_productI['model'] . ', customid ' . $this->_productI['customid'] . ', name ' . $this->_productI['name'] . ', ';
foreach($this->_productI['attributes'] as $attributes){
$callingClass->email_low_stock .= $attributes['option'] . ': ' . $attributes['value'] . ', ';
}
$callingClass->email_low_stock .= 'Stock: ' . $this->_attribute_stock_left . "\n\n";
// kuroi: End Stock by Attribute additions
}
}
}
Re: Stock by Attribute v4.0 for Zen Cart 1.3.5
Thanks MC. I'll apply that right now to the test site and verify that it works. Get back to you shortly.
RichB
Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9
MC,
That fixed the problem of the low stock messages but I've discovered other problems. I tested a product that has two attributes. One is a color selection which is identified in SBA. The other is a text attribute to add personalization. There's no information along with the mod on the dynamic dropdown options so I've experimented with them If I select enable dynamic dropdowns the text field becomes a dropdown. Different combinations of the options don't provide an actual text input field. If I turn the dynamic dropdowns off it displays as a text input field but I get an error where rb is the text I entered into the field.
Code:
PHP Fatal error: 1054:Unknown column 'rb' in 'where clause' :: select products_attributes_id
from zen_products_attributes
where options_values_id in (rb,188)
and products_id= 1165
order by products_attributes_id ==> (as called by) includes/functions/extra_functions/products_with_attributes.php on line 236 <== in includes/classes/db/mysql/query_factory.php on line 155
If you need me to go through all the different combinations on the dynamic dropdown menu in admin I'll do that for you.
Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9
Quote:
Originally Posted by
badarac
MC,
That fixed the problem of the low stock messages but I've discovered other problems. I tested a product that has two attributes. One is a color selection which is identified in SBA. The other is a text attribute to add personalization. There's no information along with the mod on the dynamic dropdown options so I've experimented with them If I select enable dynamic dropdowns the text field becomes a dropdown. Different combinations of the options don't provide an actual text input field. If I turn the dynamic dropdowns off it displays as a text input field but I get an error where rb is the text I entered into the field.
Code:
PHP Fatal error: 1054:Unknown column 'rb' in 'where clause' :: select products_attributes_id
from zen_products_attributes
where options_values_id in (rb,188)
and products_id= 1165
order by products_attributes_id ==> (as called by) includes/functions/extra_functions/products_with_attributes.php on line 236 <== in includes/classes/db/mysql/query_factory.php on line 155
If you need me to go through all the different combinations on the dynamic dropdown menu in admin I'll do that for you.
Is the text option something that is stock dependent? Ie. if someone enters text, does that affect the stock of tracked product? I ask more to try to quickly work around a somewhat known issue that dynamic dropdowns at this point does not support much more than dropdown related attributes, but is being worked on.
The lines to be affected are 216 and 222 in includes/functions/extra_functions/products_with_attributes.php
Mainly I perceive that the two if statements would need to be modified to account for text boxes. To identify exactly what is expected, need to also look back at the products_with_attributes_stock table population for text fields (appears that it could be possible for an attribute to be passed to this function that is not tracked by SBA which according to the above question of if the text box affects stock it wouldn't matter as the function attempts to compare all attributes as a unit rather than one at a time (this type of comparison is done elsewhere in the code and needs to carry over to here as well) and there is no code yet provided that allows combining 2 or more attributes as a unit and at the same time 1 or more other attributes as unit requiring 3 or more attributes to identify the product by that combination. At the moment it is either multiple single attributes, or all attributes as a group. Unfortunately text boxes have not been factored in yet, but is a basic (relatively essential) attribute type to be incorporated.
The additional testing would be beneficial to the continued development, especially since there is an interest to seeing the multiple attributes options fully supported.
Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9
Quote:
Originally Posted by
mc12345678
Is the text option something that is stock dependent? Ie. if someone enters text, does that affect the stock of tracked product? I ask more to try to quickly work around a somewhat known issue that dynamic dropdowns at this point does not support much more than dropdown related attributes, but is being worked on.
The lines to be affected are 216 and 222 in includes/functions/extra_functions/products_with_attributes.php
Mainly I perceive that the two if statements would need to be modified to account for text boxes. To identify exactly what is expected, need to also look back at the products_with_attributes_stock table population for text fields (appears that it could be possible for an attribute to be passed to this function that is not tracked by SBA which according to the above question of if the text box affects stock it wouldn't matter as the function attempts to compare all attributes as a unit rather than one at a time (this type of comparison is done elsewhere in the code and needs to carry over to here as well) and there is no code yet provided that allows combining 2 or more attributes as a unit and at the same time 1 or more other attributes as unit requiring 3 or more attributes to identify the product by that combination. At the moment it is either multiple single attributes, or all attributes as a group. Unfortunately text boxes have not been factored in yet, but is a basic (relatively essential) attribute type to be incorporated.
The additional testing would be beneficial to the continued development, especially since there is an interest to seeing the multiple attributes options fully supported.
The text attribute does not affect the stock. I can't image how a text attribute ever would though. I would guess that the answer is to modify it to exclude text attributes. If you want me to test anything I'll happily do that.
Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9
I got rid of the error by adding this
Code:
foreach ($attribute_list as $optid => $optvalid) {
if (true) {
// mc12345678 Here is one place where verification can be performed as to whether a particular attribute should be added. This is probably the best place to do the review because all aspects of the attribute are available.
if (is_numeric ($optvalid)) {
$attributes[] = $optvalid;
}
}
}
If the text attribute is added to the SBA table with a quantity the order now completes with the text attribute added to the cart. When the order is submitted I receive a low stock email with a stock value of -1. All attributes defined in the sba table have a positive stock value.
If the text attribute is removed from the SBA table it won't allow checkout because an attribute is out of stock.
I guess there must be a better way.
Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9
@badarac,
How about now? Didn't really work on dynamic dropdowns, but software needs to add the benefit of tracking stock by attribute even when say dynamic dropdowns are disabled.
Worked towards: recognzing text entry fields and upload fields for when submitting product to the cart, also recognition that the selections made do not exist. Ruling for existence at this point is: either all attributes submitted are grouped as a single variant (a shoe that is red, size 10, and has bright yellow laces) and if not grouped that way then are each individually tracked but represent only an attribute not another store product (a gift bag that allows possibly picking two items perhaps a perfume and a specific toy).
I'm thinking though that at the moment that if there are two or more each of either a textbox or upload file option names that the product will fail at adding to the cart though I have a way in mind to address that. Plan is to identify the occurrence of each of those and if one or more is identified then to OR the option_id and option_value_id for each such pair into the query that retrieves the attribute_id(s) for the combination of attributes.
The result of that being something like get the attribute_id(s) where the option_value_id is in the imploded option_value_ids for other attributes that are not specially controlled or foreach specially controlled option_name have the option_id and option_value_id values of that option_name. Also, for expandability to throw in a few well placed notifiers. Just some thoughts...
Sorry to those that have recently downloaded the latest to discover this issue.
Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9
Updated all three locations with code that should now recognize textbox entries (at least when ordering) as well as upload files. Also refined the application of some of the observer actions to only apply when the applicable item should be processed by that observer action generally speaking. In the process identified some typoes and omissions that weren't noticed by others previously.
Looking to verify/update to support ZC 1.5.5 soon.
@badarac, et al. Please confirm issues recently identified are resolved and no new issues generated... There are some known items addressed in github in particular related to read only and other non-dropdown attributes when using dynamic dropdowns as well as some "deeper" things to address such as copying SBA attributes when copying a product, etc...
Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9
Quote:
Originally Posted by
mc12345678
@badarac, et al. Please confirm issues recently identified are resolved and no new issues generated... There are some known items addressed in github in particular related to read only and other non-dropdown attributes when using dynamic dropdowns as well as some "deeper" things to address such as copying SBA attributes when copying a product, etc...
MC,
I'll download it and install on the test site today. I'll let you know shortly.
RichB