Zen Cart Logo
Forums / All Other Contributions/Addons / Stock by Attribute v4.0 addon for v1.3.5-1.3.9

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

Views: 658,382

Results 2,761 to 2,780 of 3,609
9 Aug 2017, 10:18 PM
#2761
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

fbroz:

I submitted this statement in the SQL Query Executor, and the products look good:

https://www.tokyopenshop.com/shop2/gel-ink-pens-c-11/hitec-c-p-18.html

Do I need to reverse the assignment of the pink option value to be a stock-dependent option for this test to be valid?

Nope, that update query made it so that the single entry (as far as I have directed) is no longer a factor in the overall stock evaluation and therefore the stock quantities associated with pink for that specific product are again controlled by what you enter in the sba admin table regardless of how it is entered (combined like you currently have, individual attribute(s) as in each option value listed individually with one or more option names and a single option name).

Further indicates that right now as written, having nothing in the table is a problem. Because of the "business" associated with attributes, a "database" friendly alternative to constantly checking it is needed. Whether it is an admin switch to use/not use the extra feature, or a "test" in the system that is occasionally run when manipulating the admin side to validate that at least one value is present or some other solution, but at least both the current problem and a potential solution are identified. Thank you.

31 Aug 2017, 1:39 AM
#2762
fbroz avatar

fbroz

New Zenner

Join Date:
Mar 2008
Posts:
35
Plugin Contributions:
1

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

mc12345678,

I think I am getting close with my SBA implementation, but I currently don't see attributes on some products in the shopping cart page and I wonder if you have some insights. I have other mods that may be affecting this page as well.

Products with zero or two option names associated seem fine, but products with one option name show up in the cart without their attributes listed. For example this product: https://www.tokyopenshop.com/shop2/mechanical-pencils-c-5/2020-shaker-pencil-p-624.html

I believe this "if" is failing in the tpl_shopping_cart_default.php file in my template

  if (isset($product['attributes']) && is_array($product['attributes'])) {

Here are my current settings that I think might be relevant to SBA:

Attachment 17260Attachment 17259

Thanks in advance for any help!

31 Aug 2017, 2:19 AM
#2763
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

fbroz:

mc12345678,

I think I am getting close with my SBA implementation, but I currently don't see attributes on some products in the shopping cart page and I wonder if you have some insights. I have other mods that may be affecting this page as well.

Products with zero or two option names associated seem fine, but products with one option name show up in the cart without their attributes listed. For example this product: https://www.tokyopenshop.com/shop2/mechanical-pencils-c-5/2020-shaker-pencil-p-624.html

I believe this "if" is failing in the tpl_shopping_cart_default.php file in my template

if (isset($product['attributes']) && is_array($product['attributes'])) {

> 
> Here are my current settings that I think might be relevant to SBA:
> 
> Attachment 17260Attachment 17259
> 
> Thanks in advance for any help!

Actually, and unfortunate for the formal lack of instruction, but basically, in the Dynamic Dropdowns section, the single_dropdown per the original dynamic dropdown instruction does not work properly and that if anything the multiple dropdowns option should be chosen.  As written elsewhere in this thread, the single selection feature had already been developed and was functional, it was the multiple attributes that needed to be further implemented and Dynamic Dropdowns was the closest public application that supported it, but it also had its own other "issues".  For some, they have worked out those issues, for others, they have used it as originally described. In trying not to break apart others work, I developed an alternative selection that offered the features that were missing and worked to get the desired results. 

That said, the better option for single option name attributes to a product is to leave dynamic dropdowns set to the default setting for enable dynamic dropdowns (for multiple attributes only or the value of 2), to restore the Product Info Single Attribute Display Plugin to multiple_dropdowns (though it will not have an effect with the setting above set) and then to modify the option name type (in Option Names Manager) to the SBA Select List (Dropdown) Basic option type instead of the standard Dropdown option.
13 Sep 2017, 5:27 PM
#2764
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

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

This was working fine. I'm not sure when the problem started. This occurs only on one, not very popular product.

When clicking Add to Cart, I get:
WARNING: An Error occurred, please refresh the page and try again.

Error log contains:
PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and products_id = 110
OR (options_id = 3 AND options_values_' at line 4 :: select products_attributes_id
from products_attributes
where options_values_id =
and products_id = 110
OR (options_id = 3 AND options_values_id = 0 AND products_id = 110)
order by products_attributes_id ==> (as called by) /home/agag/public_html/includes/functions/extra_functions/products_with_attributes.php on line 350 <== in /home/agag/public_html/includes/classes/db/mysql/query_factory.php on line 167

Zen Cart 1.5.1a
SBA Version 1.5.4 for Zen Cart Version 1.5.5a

The item has one attribute which is not tracked by SBA, the option type is Text. When I do add it, I get the same error. If I add a second attribute, no error. It will add to cart.
https://www.shopasgoodasgold.com/donation-gifts-c-12/blue-bandanna-p-110

13 Sep 2017, 6:06 PM
#2765
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

jeking:

This was working fine. I'm not sure when the problem started. This occurs only on one, not very popular product.

When clicking Add to Cart, I get:
WARNING: An Error occurred, please refresh the page and try again.

Error log contains:
PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and products_id = 110
OR (options_id = 3 AND options_values_' at line 4 :: select products_attributes_id
from products_attributes
where options_values_id =
and products_id = 110
OR (options_id = 3 AND options_values_id = 0 AND products_id = 110)
order by products_attributes_id ==> (as called by) /home/agag/public_html/includes/functions/extra_functions/products_with_attributes.php on line 350 <== in /home/agag/public_html/includes/classes/db/mysql/query_factory.php on line 167

Zen Cart 1.5.1a
SBA Version 1.5.4 for Zen Cart Version 1.5.5a

The item has one attribute which is not tracked by SBA, the option type is Text. When I do add it, I get the same error. If I add a second attribute, no error. It will add to cart.
https://www.shopasgoodasgold.com/donation-gifts-c-12/blue-bandanna-p-110

The version of that file is from Mar 27, 2016 or earlier (older). There is some code that was added above there at a later time to address that potential result, and actually as the plugin stands, that file no longer contains execution code (all commented out), but the installer has not been updated to remove it. If you wish to continue using that version of the software, there is a single fix for that area of the code:
At/around line 320 change:

        if ($multi) {
          $first_search = 'where options_values_id in (' . implode(',', $temp_attributes) . ')';  // This helps make a list of items where the options_values_id is compared to each individual attribute ("x","y","z")
        } else {
          $first_search = 'where options_values_id = ' . implode(',', $temp_attributes);  // This helps make a list of items where the options_values_id is compared to each individual attribute ("x","y","z")
//            $first_search = 'where options_values_id = "' . $attribute . '"';
        }

to the following by adding the below highlighted if statement:

        if ($multi) {
          $first_search = 'where options_values_id in (' . implode(',', $temp_attributes) . ')';  // This helps make a list of items where the options_values_id is compared to each individual attribute ("x","y","z")
        } else {
          $first_search = 'where options_values_id = ' . implode(',', $temp_attributes);  // This helps make a list of items where the options_values_id is compared to each individual attribute ("x","y","z")
          if (implode(',', $temp_attributes) == "") {
            $first_search = 'where options_values_id = 0';  // This helps make a list of items where the options_values_id is compared to each individual attribute ("x","y","z")
          }
//            $first_search = 'where options_values_id = "' . $attribute . '"';
        }

Also, above that code area is some missing sanitization that is shown in the current version of that function which is located in includes/classes/class.products_with_attributes_class_stock.php around line 453 of that file as available from github.

          } elseif ($optvalid == 0) {
            $specAttributes[$optid] = (int)$optvalid;
          } elseif (is_array($optvalid)) {
            if ($multi == false && count($optvalid) > 1) {
              $multi = true;
            }
            foreach($optvalid as $optid2=>$optvalid2) {
              $temp_attributes[] = (int)$optvalid2;
            }
          } elseif (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.
            $temp_attributes[] = (int)$optvalid;
          }

Lastly, though I stopped searching backwards to see when line 350 had become the sql execution line to present that error, this link shows all of the changes that have been made since March 27, 2016: https://github.com/mc12345678/Stock_By_Attributes_Combined/compare/a85542c05ba0047e10759a9be1aae464bcfb5d4d...master

13 Sep 2017, 6:13 PM
#2766
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

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

That fix did it, thank you!

I do have plans to upgrade the site and SBA. Just need to find the time. Being that I support this in my free time, that has been difficult. :-)

13 Sep 2017, 6:21 PM
#2767
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

jeking:

That fix did it, thank you!

I do have plans to upgrade the site and SBA. Just need to find the time. Being that I support this in my free time, that has been difficult. :-)
Roger that, I know the feeling...

13 Sep 2017, 8:29 PM
#2768
zoloworld avatar

zoloworld

New Zenner

Join Date:
Jul 2011
Posts:
35
Plugin Contributions:
0

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

I searched this thread and could not find info on this. I installed both the Dynamic Drpodown and the SBA add on to my Zen shop. I am getting a warning under the add to cart and am trying to figure out why. It is not allowing the drop down. here is the link here -->http://underworldfigures.com/index.php?main_page=product_info&cPath=21&products_id=67

I am using Zen cart 1.5.0

13 Sep 2017, 8:38 PM
#2769
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Zoloworld:

I searched this thread and could not find info on this. I installed both the Dynamic Drpodown and the SBA add on to my Zen shop. I am getting a warning under the add to cart and am trying to figure out why. It is not allowing the drop down. here is the link here -->http://underworldfigures.com/index.php?main_page=product_info&cPath=21&products_id=67
Ok, so when you say you installed both SBA and Dynamic Dropdowns, need to back up a second. The distribution available from https://github.com/mc12345678/Stock_By_Attributes_Combined, has or is both of those. So, the statement makes one wonder what the source of your install was.

That said, anytime you see an error (which may actually be unrelated to the above distribution), there are some easy actions to perform as identified in this ZC provided FAQ: https://www.zen-cart.com/content.php?311-warning-an-error-occurred-please-refresh-the-page-and-try-again

Whatever the case, if you would be so kind as to identify how the site got to where it is in relation to the above and then if you need assistance interpreting the associated information (preferably as it relates to the install as described above) then feel free to post the contents here (sanitize out any specific file path information of concern and please press the # button in the message box toolbar just before pasting.

13 Sep 2017, 8:55 PM
#2770
zoloworld avatar

zoloworld

New Zenner

Join Date:
Jul 2011
Posts:
35
Plugin Contributions:
0

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

mc12345678:

Ok, so when you say you installed both SBA and Dynamic Dropdowns, need to back up a second. The distribution available from https://github.com/mc12345678/Stock_By_Attributes_Combined, has or is both of those. So, the statement makes one wonder what the source of your install was.

That said, anytime you see an error (which may actually be unrelated to the above distribution), there are some easy actions to perform as identified in this ZC provided FAQ: https://www.zen-cart.com/content.php?311-warning-an-error-occurred-please-refresh-the-page-and-try-again

Whatever the case, if you would be so kind as to identify how the site got to where it is in relation to the above and then if you need assistance interpreting the associated information (preferably as it relates to the install as described above) then feel free to post the contents here (sanitize out any specific file path information of concern and please press the # button in the message box toolbar just before pasting.

Thank you so much for the reply.
I downloaded it from the plug-ins section. It did not have both as I was looking after I added the SQL info. I am going to run a debug log to see if an error shows up.

13 Sep 2017, 8:56 PM
#2771
zoloworld avatar

zoloworld

New Zenner

Join Date:
Jul 2011
Posts:
35
Plugin Contributions:
0

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

[13-Sep-2017 13:41:24 America/Phoenix] PHP Fatal error: 1146:Table '.zen_zen_products_with_attributes_stock' doesn't exist :: select quantity from zen_zen_products_with_attributes_stock where products_id = '67' AND quantity > 0 in /home/content/84/2009684/html/underworld/includes/classes/db/mysql/query_factory.php on line 101

13 Sep 2017, 9:07 PM
#2772
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Zoloworld:

[13-Sep-2017 13:41:24 America/Phoenix] PHP Fatal error: 1146:Table '.zen_zen_products_with_attributes_stock' doesn't exist :: select quantity from zen_zen_products_with_attributes_stock where products_id = '67' AND quantity > 0 in /home/content/84/2009684/html/underworld/includes/classes/db/mysql/query_factory.php on line 101

Yeah, that's problem number one with the version of Dynamic Dropdowns available for download from this site (corrected in the incorporation referenced in my last post). There are a number of other issues, such as the install requires that all product that have an attribute to be tracked by SBA (not the case with the way it is implemented) and if I remember correctly every product had to have attributes as well... been a few years since I've looked at how it was implemented.

My suggestion would be to download the version from github (not yet posted to the ZC website because the instructions need a major overhaul to reflect the full capability and ways to implement) and replace/incorporate the files from that install... you will be much more satisfied. Can look back over the last couple of pages of this thread for install "sequence".

13 Sep 2017, 9:07 PM
#2773
zoloworld avatar

zoloworld

New Zenner

Join Date:
Jul 2011
Posts:
35
Plugin Contributions:
0

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

Zoloworld:

[13-Sep-2017 13:41:24 America/Phoenix] PHP Fatal error: 1146:Table '.zen_zen_products_with_attributes_stock' doesn't exist :: select quantity from zen_zen_products_with_attributes_stock where products_id = '67' AND quantity > 0 in /home/content/84/2009684/html/underworld/includes/classes/db/mysql/query_factory.php on line 101

This is also where I downloaded the file https://www.zen-cart.com/showthread.php?47180-Stock-by-Attribute-v4-0-addon-for-v1-3-5-1-3-9 i used as it was from Zen 1.5.0

13 Sep 2017, 9:08 PM
#2774
zoloworld avatar

zoloworld

New Zenner

Join Date:
Jul 2011
Posts:
35
Plugin Contributions:
0

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

mc12345678:

Yeah, that's problem number one with the version of Dynamic Dropdowns available for download from this site (corrected in the incorporation referenced in my last post). There are a number of other issues, such as the install requires that all product that have an attribute to be tracked by SBA (not the case with the way it is implemented) and if I remember correctly every product had to have attributes as well... been a few years since I've looked at how it was implemented.

My suggestion would be to download the version from github (not yet posted to the ZC website because the instructions need a major overhaul to reflect the full capability and ways to implement) and replace/incorporate the files from that install... you will be much more satisfied. Can look back over the last couple of pages of this thread for install "sequence".

Thank you so much for the advice. I will use the one you linked.

13 Sep 2017, 9:14 PM
#2775
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Zoloworld:

Thank you so much for the advice. I will use the one you linked.
While there are some minor differences between ZC 1.5.1 and 1.5.0 in the areas touched by the plugin, I would expect that the changes made to support SBA in the 1.5.1 files could be applied to 1.5.0, but haven't tried going back that far. I do not expect any php related problems just that some logic in some areas may have been written slightly differently between the two versions.

13 Sep 2017, 9:21 PM
#2776
zoloworld avatar

zoloworld

New Zenner

Join Date:
Jul 2011
Posts:
35
Plugin Contributions:
0

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

mc12345678:

While there are some minor differences between ZC 1.5.1 and 1.5.0 in the areas touched by the plugin, I would expect that the changes made to support SBA in the 1.5.1 files could be applied to 1.5.0, but haven't tried going back that far. I do not expect any php related problems just that some logic in some areas may have been written slightly differently between the two versions.

I went ahead and loaded the files. I am noticing the same error. I am curious if there is any SQL lines I need to add.

13 Sep 2017, 9:27 PM
#2777
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Zoloworld:

I went ahead and loaded the files. I am noticing the same error. I am curious if there is any SQL lines I need to add.
I really should know the real filename, but I didn't come up with it and haven't changed it because there is so much "history" already. There is a file in the root of your admin, something like stock_by_attr_install.php. Once you login to your admin, point your browser to that file within your admin directory. Perform the install/upgrade. This will execute the sql needed for the plugin. Your existing database table for SBA will remain "untouched" (not be deleted or cleared), but settings for SBA (which includes Dynamic Dropdowns) will be reset to their default values. Still want to modify that behavior, but...

For others, in a fresh install of SBA, the files can be placed and will not interfere with normal operation and not be "obvious" that SBA is installed until that install file is accessed and the install/upgrade performed.

13 Sep 2017, 9:43 PM
#2778
zoloworld avatar

zoloworld

New Zenner

Join Date:
Jul 2011
Posts:
35
Plugin Contributions:
0

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

Thank you so much!! It works now! And yes, It can work with 1.5.0!

13 Sep 2017, 10:06 PM
#2779
zoloworld avatar

zoloworld

New Zenner

Join Date:
Jul 2011
Posts:
35
Plugin Contributions:
0

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

fbroz:

mc12345678,

I think I am getting close with my SBA implementation, but I currently don't see attributes on some products in the shopping cart page and I wonder if you have some insights. I have other mods that may be affecting this page as well.

Products with zero or two option names associated seem fine, but products with one option name show up in the cart without their attributes listed. For example this product: https://www.tokyopenshop.com/shop2/mechanical-pencils-c-5/2020-shaker-pencil-p-624.html

I believe this "if" is failing in the tpl_shopping_cart_default.php file in my template

if (isset($product['attributes']) && is_array($product['attributes'])) {

> 
> Here are my current settings that I think might be relevant to SBA:
> 
> Attachment 17260Attachment 17259
> 
> Thanks in advance for any help!

I cannot find this information on the left. I downloaded the info and cannot find it.
13 Sep 2017, 10:16 PM
#2780
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Zoloworld:

I cannot find this information on the left. I downloaded the info and cannot find it.
If this is something you are trying to resolve about your install could you please provide some more information? Last that I spoke with fbroz about his install once the default settings for stock (as modified by SBA) and Dynamic Dropdowns (located either one above or one below the configuration->stock option. Trust me when I say it seems almost invisible even when it is blindly there.

There may be an issue though as a result of having installed the original version of it followed by how SBA follows up, I'm not sure. If it isn't there (seriously look really hard and carefully) then we'll talk about what is needed to resolve.