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,369

Results 2,861 to 2,880 of 3,609
4 Jan 2018, 7:33 PM
#2861
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

All the files check out... thank you for the quick response.
It must be a db connection issue but it is a new db and I simply imported the data from the active site into the new db to test it. It stands alone right now as a new cart down for maintenance. I'll try and approach it from a db path angle and see if there is an issue there.

4 Jan 2018, 7:47 PM
#2862
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

I can navigate to the stock_by_attr_install.php file. Any recommendation on what to choose in the drop down to make it install? Default SQL looks like the thing to do.... nope, scratch that. Full/Upgrade i reckon.

So here is what I got:
FAILURES:
There were ERRORs Reported.
Review results below:

Results from the selection Full Install: (Errors!)

File needs to be removed: /home/mysite/public_html/admin/ajax/jquery.form.js
File needs to be removed: /home/mysite/public_html/admin/ajax/jquery-1.10.2.min.js

Clean-Up, Removing from configuration:
• Deleted STOCK_SHOW_IMAGE
• Deleted STOCK_SHOW_LOW_IN_CART
• Deleted STOCK_SHOW_ATTRIB_LEVEL_STOCK
• Deleted STOCK_SHOW_ORIGINAL_PRICE_STRUCK
• Deleted STOCK_SET_SBA_SEARCHBOX
• Deleted STOCK_SBA_SEARCHLIST
• Deleted STOCK_SBA_DISPLAY_CUSTOMID
• Deleted SBA_SHOW_IMAGE_ON_PRODUCT_INFO
• Deleted PRODUCTS_OPTIONS_TYPE_SELECT_SBA
• Deleted ATTRIBUTES_SBA_DISPLAY_CUSTOMID
• Deleted SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO
• Deleted STOCK_SBA_CUSTOM_FOR_MODEL

Clean-Up, Removing from products_options_types:
• Moving option types from SBA Select List (Dropdown) Basic to an equivalent type to prepare for removal.
• Deleted products_options_types_name

Clean-Up, Removing from admin_pages:
• Deleted productsWithAttributesStock
• Deleted productsWithAttributesStockSetup
• Deleted productsWithAttributesStockAjax

Clean-Up, Removing from configuration:
• Deleted PRODINFO_ATTRIBUTE_PLUGIN_SINGLE
• Deleted PRODINFO_ATTRIBUTE_PLUGIN_MULTI
• Deleted PRODINFO_ATTRIBUTE_SHOW_OUT_OF_STOCK
• Deleted PRODINFO_ATTRIBUTE_MARK_OUT_OF_STOCK
• Deleted PRODINFO_ATTRIBUTE_OUT_OF_STOCK_MSGLINE
• Deleted PRODiNFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK
• Deleted STOCK_SET_SBA_NUMRECORDS
• Deleted PRODINFO_ATTRIBUTE_DYNAMIC_STATUS
• Deleted SBA_ZC_DEFAULT
• Deleted PRODINFO_ATTRIBUTE_POPUP_OUT_OF_STOCK
• Deleted PRODINFO_ATTRIBUTE_DYNAMIC_STOCK_READ_ONLY

Clean-Up, Removing Dynamic Dropdowns from admin_pages:
• Deleted configDynamicDropdownSBA
• Deleted Dynamic Drop Downs from configuration_group

Adding to admin_pages:
• Inserted into admin_pages productsWithAttributesStock.

Adding to configuration (SBA option switches):
Inserted into configuration:
• STOCK_SHOW_IMAGE
• STOCK_SHOW_LOW_IN_CART
• STOCK_SHOW_ATTRIB_LEVEL_STOCK
• STOCK_SHOW_ORIGINAL_PRICE_STRUCK
• STOCK_SET_SBA_SEARCHBOX
• STOCK_SBA_SEARCHLIST
• STOCK_SBA_DISPLAY_CUSTOMID
• SBA_SHOW_IMAGE_ON_PRODUCT_INFO

Adding to admin_pages:
• Inserted into configuration_group Dynamic Drop Downs.
• Inserted into admin_pages configDynamicDropdownSBA.

Adding to configuration (Dynamic Dropdowns option switches):
Inserted into configuration:
• PRODINFO_ATTRIBUTE_PLUGIN_SINGLE
• PRODINFO_ATTRIBUTE_PLUGIN_MULTI
• PRODINFO_ATTRIBUTE_SHOW_OUT_OF_STOCK
• PRODINFO_ATTRIBUTE_MARK_OUT_OF_STOCK
• PRODINFO_ATTRIBUTE_OUT_OF_STOCK_MSGLINE
• PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK
• STOCK_SET_SBA_NUMRECORDS

• products_with_attributes_stock Table Fields: stock_id | products_id | stock_attributes | quantity | sort |

Altered Table products_with_attributes_stock to add DEFAULT value of 0.
Added customid field to table products_with_attributes_stock.
Added title field to table products_with_attributes_stock.
Added product_attribute_combo field to table products_with_attributes_stock.

Added Table orders_products_with_attributes_stock:

Added New Table products_with_attributes_stock_attributes_non_stock.

Adding to admin_pages:
• Inserted into admin_pages productsWithAttributesStockSetup.
Updating PRODUCTS_OPTIONS_TYPE_SELECT, UPLOAD_PREFIX and TEXT_PREFIX
Updated PRODUCTS_OPTIONS_TYPE_SELECT, UPLOAD_PREFIX and TEXT_PREFIX

Verifiying products_options_types:

Finding highest products_options_types value:

Adding to products_options_types:
• Inserted into products_options_types "SBA Select List (Dropdown) Basic".

Adding to configuration:
• Inserted into configuration "Selection list product option type (SBA)" .
File not found: /home/mysite/public_html/mysite/includes/modules/pages/checkout_success/header_php_sba.php

4 Jan 2018, 7:51 PM
#2863
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

athena:

All the files check out... thank you for the quick response.
It must be a db connection issue but it is a new db and I simply imported the data from the active site into the new db to test it. It stands alone right now as a new cart down for maintenance. I'll try and approach it from a db path angle and see if there is an issue there.

While the database install itself doesn't really care what version of ZC it is on and I realize the question relates to SBA, but if all that was done was to import the old 1.5.1 database into the database referenced by ZC 1.5.4 and nothing else, then there are other steps still to be taken such as updating that database to ZC 1.5.4. Otherwise, again, if the file stock_by_attr_install.php is accessed, that should at least initiate the "install" of the admin's configuration option to again return to that same menu. Then you can do an install/upgrade, or a remove (without removing the database table(s)) followed by an install/upgrade in order to make the other options/settings again available. There really should generally be no other modifications necessary to move from the older store to a newer yet still old store. If there are, please advise so that can either incorporate into the code to address automatically or incorporate into some level of instruction beyond a potentially "lost" post.

4 Jan 2018, 9:33 PM
#2864
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

athena:

I can navigate to the stock_by_attr_install.php file. Any recommendation on what to choose in the drop down to make it install? Default SQL looks like the thing to do.... nope, scratch that. Full/Upgrade i reckon.

So here is what I got:
FAILURES:
There were ERRORs Reported.
Review results below:

Results from the selection Full Install: (Errors!)

**File needs to be removed: /home/mysite/public_html/admin/ajax/jquery.form.js
File needs to be removed: /home/mysite/public_html/admin/ajax/jquery-1.10.2.min.js
**
Clean-Up, Removing from configuration:
• Deleted STOCK_SHOW_IMAGE
• Deleted STOCK_SHOW_LOW_IN_CART
• Deleted STOCK_SHOW_ATTRIB_LEVEL_STOCK
• Deleted STOCK_SHOW_ORIGINAL_PRICE_STRUCK
• Deleted STOCK_SET_SBA_SEARCHBOX
• Deleted STOCK_SBA_SEARCHLIST
• Deleted STOCK_SBA_DISPLAY_CUSTOMID
• Deleted SBA_SHOW_IMAGE_ON_PRODUCT_INFO
• Deleted PRODUCTS_OPTIONS_TYPE_SELECT_SBA
• Deleted ATTRIBUTES_SBA_DISPLAY_CUSTOMID
• Deleted SBA_SHOW_OUT_OF_STOCK_ATTR_ON_PRODUCT_INFO
• Deleted STOCK_SBA_CUSTOM_FOR_MODEL

Clean-Up, Removing from products_options_types:
• Moving option types from SBA Select List (Dropdown) Basic to an equivalent type to prepare for removal.
• Deleted products_options_types_name

Clean-Up, Removing from admin_pages:
• Deleted productsWithAttributesStock
• Deleted productsWithAttributesStockSetup
• Deleted productsWithAttributesStockAjax

Clean-Up, Removing from configuration:
• Deleted PRODINFO_ATTRIBUTE_PLUGIN_SINGLE
• Deleted PRODINFO_ATTRIBUTE_PLUGIN_MULTI
• Deleted PRODINFO_ATTRIBUTE_SHOW_OUT_OF_STOCK
• Deleted PRODINFO_ATTRIBUTE_MARK_OUT_OF_STOCK
• Deleted PRODINFO_ATTRIBUTE_OUT_OF_STOCK_MSGLINE
• Deleted PRODiNFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK
• Deleted STOCK_SET_SBA_NUMRECORDS
• Deleted PRODINFO_ATTRIBUTE_DYNAMIC_STATUS
• Deleted SBA_ZC_DEFAULT
• Deleted PRODINFO_ATTRIBUTE_POPUP_OUT_OF_STOCK
• Deleted PRODINFO_ATTRIBUTE_DYNAMIC_STOCK_READ_ONLY

Clean-Up, Removing Dynamic Dropdowns from admin_pages:
• Deleted configDynamicDropdownSBA
• Deleted Dynamic Drop Downs from configuration_group

Adding to admin_pages:
• Inserted into admin_pages productsWithAttributesStock.

Adding to configuration (SBA option switches):
Inserted into configuration:
• STOCK_SHOW_IMAGE
• STOCK_SHOW_LOW_IN_CART
• STOCK_SHOW_ATTRIB_LEVEL_STOCK
• STOCK_SHOW_ORIGINAL_PRICE_STRUCK
• STOCK_SET_SBA_SEARCHBOX
• STOCK_SBA_SEARCHLIST
• STOCK_SBA_DISPLAY_CUSTOMID
• SBA_SHOW_IMAGE_ON_PRODUCT_INFO

Adding to admin_pages:
• Inserted into configuration_group Dynamic Drop Downs.
• Inserted into admin_pages configDynamicDropdownSBA.

Adding to configuration (Dynamic Dropdowns option switches):
Inserted into configuration:
• PRODINFO_ATTRIBUTE_PLUGIN_SINGLE
• PRODINFO_ATTRIBUTE_PLUGIN_MULTI
• PRODINFO_ATTRIBUTE_SHOW_OUT_OF_STOCK
• PRODINFO_ATTRIBUTE_MARK_OUT_OF_STOCK
• PRODINFO_ATTRIBUTE_OUT_OF_STOCK_MSGLINE
• PRODINFO_ATTRIBUTE_NO_ADD_OUT_OF_STOCK
• STOCK_SET_SBA_NUMRECORDS

• products_with_attributes_stock Table Fields: stock_id | products_id | stock_attributes | quantity | sort |

Altered Table products_with_attributes_stock to add DEFAULT value of 0.
Added customid field to table products_with_attributes_stock.
Added title field to table products_with_attributes_stock.
Added product_attribute_combo field to table products_with_attributes_stock.

Added Table orders_products_with_attributes_stock:

Added New Table products_with_attributes_stock_attributes_non_stock.

Adding to admin_pages:
• Inserted into admin_pages productsWithAttributesStockSetup.
Updating PRODUCTS_OPTIONS_TYPE_SELECT, UPLOAD_PREFIX and TEXT_PREFIX
Updated PRODUCTS_OPTIONS_TYPE_SELECT, UPLOAD_PREFIX and TEXT_PREFIX

Verifiying products_options_types:

Finding highest products_options_types value:

Adding to products_options_types:
• Inserted into products_options_types "SBA Select List (Dropdown) Basic".

Adding to configuration:
• Inserted into configuration "Selection list product option type (SBA)" .
** File not found: /home/mysite/public_html/mysite/includes/modules/pages/checkout_success/header_php_sba.php**

Full/Upgrade is/was a good choice generally speaking. Does look like one file (at least) was not put to the server as identified by the last line of the above response (File not found: /home/mysite/public_html/mysite/includes/modules/pages/checkout_success/header_php_sba.php). Then of course there are a few files that should be removed from the server (somehow left over from the "old" install???) as it relates to SBA. If something else accesses them, then so be it, but SBA does not need those files as located at that location.

5 Jan 2018, 4:13 PM
#2865
athena avatar

athena

Totally Zenned

Join Date:
Jan 2006
Location:
NM
Posts:
740
Plugin Contributions:
0

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

I believe I must have accessed the install page once before and used it to try and uninstall as I do recall running it to check if all the files were present. I then must have methodically gone through and removed then re-uploaded the pages, missing checkout_success/header_php_sba.php. It is now replaced.

I checked all my other mods and none are using the ajax/.js files so removed. Everything appears to be in place in the admin now. I will put this install through its paces to make sure SBA is working. Just one more mod and we can go live with 1.5.4. Thank you so much again

5 Jan 2018, 4:31 PM
#2866
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

athena:

I believe I must have accessed the install page once before and used it to try and uninstall as I do recall running it to check if all the files were present. I then must have methodically gone through and removed then re-uploaded the pages, missing checkout_success/header_php_sba.php. It is now replaced.

I checked all my other mods and none are using the ajax/.js files so removed. Everything appears to be in place in the admin now. I will put this install through its paces to make sure SBA is working. Just one more mod and we can go live with 1.5.4. Thank you so much again

Good to hear and glad is working. Please report any issues back so that they may be addressed even if you self fix them.

21 Jan 2018, 5:48 PM
#2867
catmint avatar

catmint

New Zenner

Join Date:
Jan 2016
Location:
North Yorks UK
Posts:
6
Plugin Contributions:
0

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

Hi

Many thanks for putting the work into this addon, it is a great help. I am how ever having a problem with the stock quantity and out of stock notifications in the drop down box, in that I cannot get them to appear. I have been through the previous posts and tried what has been suggested before but to no avail. I am probably doing something stupid, but it is beyond me now.

ZC is 1.5.4 and the addon I used is from https://github.com/mc12345678/Stock_By_Attributes_Combined, downloaded this morning using the 1.5.4 files. The site is live and otherwise works fine. The only other addon installed is multi cross sell

A test page for a product is here
https://www.catmint.biz/shop/index.php?main_page=product_info&cPath=14&products_id=102&zenid=t5kvhnoqh8hjbvtkgpbcn7llo3

"Right hand drive set" has a stock of 3
"Left hand drive set" has a stock of 0
"Right hand drive box dash only (no passenger side)" has a stock of 2
"Leftt hand drive box dash only (no passenger side)" has a stock of 0

Configuration/stock is as follows

Subtract stock true
Allow Checkout false
Mark product out of stock ***
Stock Re-order level 5
Products status in Catalog when out of stock should be set to 1
Show Sold Out Image in place of Add to Cart 1
Product Quantity Decimals 0
Show Shopping Cart - Delete Checkboxes or Delete Button 3
Show Shopping Cart - Update Cart Button Location 3
Show New Products on empty Shopping Cart Page 1
Show Featured Products on empty Shopping Cart Page 2
Show Special Products on empty Shopping Cart Page 3
Show Upcoming Products on empty Shopping Cart Page 4
Show Notice of Combining Shopping Cart on Login 1
SBA Show Available Stock Level in Cart (when less than order) true
SBA Display Images in Admin true Info
SBA Show Stock Level on Product Info Page true
SBA Original Price Struck Through true
SBA Display Search Box Only false
SBA Display Search List Box true
SBA Display Custom ID true
SBA Display Attributes Images 1
SBA Display Non-DD Out-of-Stock Attributes 1
SBA CustomID replaces products_model 1

Configuration/dynamic drop downs

Product Info Single Attribute Display Plugin sba_sequenced_dropdowns
Product Info Multiple Attribute Display Plugin sba_sequenced_dropdowns
Use ZC default HTML Attribute Tags false
Show Out of Stock Attributes True
Mark Out of Stock Attributes Left
SBA Number of Records to Displayed 25
Display Out of Stock Message Line True
Prevent Adding Out of Stock to Cart True
Display Javascript Popup for Out-of-Stock Selection True
Count Read Only as Stock false

Any help would be greatly appreciated

Many thanks in advance, Gordon

21 Jan 2018, 7:36 PM
#2868
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

A very informative post, thank you for the details. There was one setting missing from the dynamic dropdowns section, but looking at the site I would say that I was able to determine its setting.

For the option name: Box Dash selection, go back into admin->catalog->option names manager and modify the type of attribute from "dropdown" to the one that is likely at the end of the list having the words SBA Select in it...

It appears that the option type is the standard dropdown and SBA has not been written to just "take over" aspects such as that.

22 Jan 2018, 9:48 AM
#2869
catmint avatar

catmint

New Zenner

Join Date:
Jan 2016
Location:
North Yorks UK
Posts:
6
Plugin Contributions:
0

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

Many thanks for the reply and help. I think the settings you mentioned are as they should be.

Sorry, I thought I had caught all the details - the missing dropdowns setting is to "enable dynamic dropdowns" and is set to 1, with the sub menu box set for "On for all SBA Tracked"

In the options name manager, the dropdown option is set to " SBA Select List (Dropdown) Basic"

Would there be anything in the SBA setup that I may have missed? When installing I did the file check which came out OK and then ran the full database install. I also ran the stock_by_attr_install.php from my browser, but I am not sure if it was successful.

Thanks again, Gordon

22 Jan 2018, 10:03 AM
#2870
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

catmint:

Many thanks for the reply and help. I think the settings you mentioned are as they should be.

Sorry, I thought I had caught all the details - the missing dropdowns setting is to "enable dynamic dropdowns" and is set to 1, with the sub menu box set for "On for all SBA Tracked"

In the options name manager, the dropdown option is set to " SBA Select List (Dropdown) Basic"

Would there be anything in the SBA setup that I may have missed? When installing I did the file check which came out OK and then ran the full database install. I also ran the stock_by_attr_install.php from my browser, but I am not sure if it was successful.

Thanks again, Gordon
Restore "enable dynamic dropdowns" to its default value of 2 (on for multiple attributes only) and you should be a-okay. It's an "under-the-hood" thing. The SBA Select dropdowns were incorporated well before Dynamic Dropdowns were merged into this fileset and were functional out-of-the-box. DD still needs/needed work, so they were kept separate.

Anyways, that should get the stock quantity showing (even though those items out-of-stock should not be allowed to be added to the cart).

22 Jan 2018, 10:44 AM
#2871
catmint avatar

catmint

New Zenner

Join Date:
Jan 2016
Location:
North Yorks UK
Posts:
6
Plugin Contributions:
0

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

Thanks, I have set the enable dynamic dropdowns to 2, but frustratingly the stock quantities are still not showing (did a clean page refresh as well on the web site just in case).

Thanks, Gordon

22 Jan 2018, 11:38 AM
#2872
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

catmint:

Thanks, I have set the enable dynamic dropdowns to 2, but frustratingly the stock quantities are still not showing (did a clean page refresh as well on the web site just in case).

Thanks, Gordon
Besides all of the files located in the includes and the admin base directory, there are two additional files that must be in the proper place to further support SBA: includes/modules/YOUR_TEMPLATE/attributes.php (which adds capability to the file rather than limit it) and includes/templates/YOUR_TEMPLATE/templates/tpl_modules_attributes.php both of which are found under the base fileset having the includes directory.

22 Jan 2018, 1:19 PM
#2873
catmint avatar

catmint

New Zenner

Join Date:
Jan 2016
Location:
North Yorks UK
Posts:
6
Plugin Contributions:
0

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

Brilliant, it was the attributes.php that was in the wrong place. Stock levels are now present, although the £ sign has changed to the coding word rather than the symbol, but I am not bothered about that as the priority is the stock attributes.

Many many thanks for your prompt help, it is greatly appreciated, Gordon

22 Jan 2018, 1:34 PM
#2874
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

catmint:

Brilliant, it was the attributes.php that was in the wrong place. Stock levels are now present, although the £ sign has changed to the coding word rather than the symbol, but I am not bothered about that as the priority is the stock attributes.

Many many thanks for your prompt help, it is greatly appreciated, Gordon

Welcome. Besides having instruction to identify what files/folders need to go where, it seems that the installer possibly could attempt to verify the presence of the needed file(s), though in some cases one may choose to modify the base version instead of the override and the plugin could/should recognize this possibility with regards to file existence. The "next" step to that is some sort of validation that whatever file(s) were not stored in the expected location that they still at least offer the expected operation.

As to the currency display issue. I'm not yet sure if that is a general html in a dropdown problem or if there is a "conversion" not performed that should be in generating the text of the line. Since the additional cost is not on one of the "shorter" entries, I hadn't previously seen how it was displayed to know whether there was an issue created by using the SBA dropdown or not... seems unusual that it would have changed because really SBA was using the same data that was otherwise available and basically just adding to it instead of replacing it.

Will look into that because the sanitized currency symbol on the dropdown doesn't seem right. Thanks for reporting it.

22 Jan 2018, 3:25 PM
#2875
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

catmint:

Brilliant, it was the attributes.php that was in the wrong place. Stock levels are now present, although the £ sign has changed to the coding word rather than the symbol, but I am not bothered about that as the priority is the stock attributes.

Many many thanks for your prompt help, it is greatly appreciated, Gordon

This is because of a change that was incorporated into lines 192/193 of includes/classes/class.products_with_attributes_class_stock.php to sanitize to the maximum extent the name that would be displayed in the drop-down list, specifically to capture any other potential needed sanitization that was not included in line 192. I might therefore suggest removing the comment on line 192 and then commenting out line 193. This would at least restore the proper display of the text and currency symbol until possibly another alternative is considered.

Therefore change:

      //close tag and display text
//      $field .= '>' . zen_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>' . "\n";
      $field .= '>' . zen_output_string_protected($values[$i]['text']) . '</option>' . "\n";

to:

      //close tag and display text
      $field .= '>' . zen_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>' . "\n";
//      $field .= '>' . zen_output_string_protected($values[$i]['text']) . '</option>' . "\n";

I may even suggest modifying that a little to:

      //close tag and display text
      $field .= '>' . zen_output_string($values[$i]['text'],  array('"' => '"', '\'' => ''', '<' =>  '<', '>' => '>', ' & ' => ' & ')) . '</option>' . "\n";
//      $field .= '>' . zen_output_string_protected($values[$i]['text']) . '</option>' . "\n";

to address converting "lone" '&' symbols to their corresponding html entity, but leaving combination type symbols (```
£


Note that the "lone" symbol is identified by having a space before and after the & which is included in the replaced value(s) as well.. Unfortunately, this replacement will not work if the only content in the field is an &.  In that case the & will not be "converted".
22 Jan 2018, 4:21 PM
#2876
catmint avatar

catmint

New Zenner

Join Date:
Jan 2016
Location:
North Yorks UK
Posts:
6
Plugin Contributions:
0

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

Great, that has sorted that out as well.

Many thanks again for your support, Gordon

31 Jan 2018, 3:32 PM
#2877
tmpinsnty avatar

tmpinsnty

New Zenner

Join Date:
Jun 2016
Location:
Minneapolis, MN
Posts:
37
Plugin Contributions:
0

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

This is a fresh install of ZenCart 1.5.5f. I just built this web server and it has the latest stable releases to my knowledge. I'm on Debian 9. This is my Server info from my admin.
Attachment 17675

I have Categories center box for index page, COWOA, One page, Dynamic Price Update, Debug backstrace, and my payment/shipping modules installed.

I keep getting this error when I try to run the install script:
[31-Jan-2018 14:42:28 UTC] Request URI: /MY_ADMIN/stock_by_attr_install.php?selectSBAinstall=installAll&getSBAinstallPage=Run+Script, IP address: 173.8.96.194
#1 trigger_error() called at [/var/www/clients/client0/web1/web/includes/classes/db/mysql/query_factory.php:171]
#2 queryFactory->show_error() called at [/var/www/clients/client0/web1/web/includes/classes/db/mysql/query_factory.php:143]
#3 queryFactory->set_error() called at [/var/www/clients/client0/web1/web/includes/classes/db/mysql/query_factory.php:270]
#4 queryFactory->Execute() called at [/var/www/clients/client0/web1/web/MY_ADMIN/stock_by_attr_install.php:963]
#5 addSBAtable() called at [/var/www/clients/client0/web1/web/MY_ADMIN/stock_by_attr_install.php:2784]

[31-Jan-2018 14:42:28 UTC] PHP Fatal error: 1071:Specified key was too long; max key length is 767 bytes :: CREATE TABLE IF NOT EXISTS products_with_attributes_stock (
stock_id int(11) NOT NULL AUTO_INCREMENT,
products_id int(11) NOT NULL,
product_attribute_combo varchar(255) DEFAULT NULL,
stock_attributes varchar(255) NOT NULL,
quantity float NOT NULL DEFAULT '0',
sort int(11) NOT NULL DEFAULT '0',
customid varchar(255) DEFAULT NULL,
title varchar(100) DEFAULT NULL,
PRIMARY KEY (stock_id),
UNIQUE KEY idx_products_id_stock_attributes (products_id,stock_attributes),
UNIQUE KEY idx_products_id_attributes_id (product_attribute_combo),
UNIQUE KEY idx_customid (customid)
); ==> (as called by) /var/www/clients/client0/web1/web/MY_ADMIN/stock_by_attr_install.php on line 963 <== in /var/www/clients/client0/web1/web/includes/classes/db/mysql/query_factory.php on line 171

Is it a MySQL/MariaDB issue? if so how can I remedy it?

31 Jan 2018, 4:40 PM
#2878
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

tmpinsnty:

This is a fresh install of ZenCart 1.5.5f. I just built this web server and it has the latest stable releases to my knowledge. I'm on Debian 9. This is my Server info from my admin.
Attachment 17675

I have Categories center box for index page, COWOA, One page, Dynamic Price Update, Debug backstrace, and my payment/shipping modules installed.

I keep getting this error when I try to run the install script:
```
[31-Jan-2018 14:42:28 UTC] Request URI: /MY_ADMIN/stock_by_attr_install.php?selectSBAinstall=installAll&getSBAinstallPage=Run+Script, IP address: 173.8.96.194
#1 trigger_error() called at [/var/www/clients/client0/web1/web/includes/classes/db/mysql/query_factory.php:171]
#2 queryFactory->show_error() called at [/var/www/clients/client0/web1/web/includes/classes/db/mysql/query_factory.php:143]
#3 queryFactory->set_error() called at [/var/www/clients/client0/web1/web/includes/classes/db/mysql/query_factory.php:270]
#4 queryFactory->Execute() called at [/var/www/clients/client0/web1/web/MY_ADMIN/stock_by_attr_install.php:963]
#5 addSBAtable() called at [/var/www/clients/client0/web1/web/MY_ADMIN/stock_by_attr_install.php:2784]

[31-Jan-2018 14:42:28 UTC] PHP Fatal error: 1071:Specified key was too long; max key length is 767 bytes :: CREATE TABLE IF NOT EXISTS products_with_attributes_stock (
stock_id int(11) NOT NULL AUTO_INCREMENT,
products_id int(11) NOT NULL,
product_attribute_combo varchar(255) DEFAULT NULL,
stock_attributes varchar(255) NOT NULL,
quantity float NOT NULL DEFAULT '0',
sort int(11) NOT NULL DEFAULT '0',
customid varchar(255) DEFAULT NULL,
title varchar(100) DEFAULT NULL,
PRIMARY KEY (stock_id),
UNIQUE KEY idx_products_id_stock_attributes (products_id,stock_attributes),
UNIQUE KEY idx_products_id_attributes_id (product_attribute_combo),
UNIQUE KEY idx_customid (customid)
); ==> (as called by) /var/www/clients/client0/web1/web/MY_ADMIN/stock_by_attr_install.php on line 963 <== in /var/www/clients/client0/web1/web/includes/classes/db/mysql/query_factory.php on line 171

> 
> Is it a MySQL/MariaDB issue? if so how can I remedy it?


More than likely the key that is causing the issue on the current system configuration is:

UNIQUE KEY idx_products_id_stock_attributes (products_id,stock_attributes),


as a result of stock_attributes being 255 characters (~765 Bytes) combined with products_id being an integer (4 Bytes) puts the key over the 767 Bytes limit by 2 bytes (when using utf8, if using utf8mb4, then well the result is 1020 Bytes instead of the 767).

So to correct this condition, there are a couple of things that could be done, possibly the most "flexible" is to modify the table definition such that the varchar related fields have a small enough size that the database could eventually be transitioned to utf8mb4 (if not already) and support continuing to have the unique keys identified above.  (As a result of this notification may need to rethink that assignment of a unique key anyways.  The code tends to prevent two or more entries from clashing at least for that particular entry, so it may not even be necessary, but would only suggest that after additional review).

There are some settings that can be applied if the mySql version were 5.6 or above and MariaDb 10.0 and above; however, in trying to keep things applicable to more systems, a more appropriate solution (to address the key issue only) would be one that supports continuing having the key and potential future use of utf8mb4 to do this, I would suggest changing:

CREATE TABLE IF NOT EXISTS products_with_attributes_stock (
stock_id int(11) NOT NULL AUTO_INCREMENT,
products_id int(11) NOT NULL,
product_attribute_combo varchar(255) DEFAULT NULL,
stock_attributes varchar([B]255[/B]) NOT NULL,
quantity float NOT NULL DEFAULT '0',
sort int(11) NOT NULL DEFAULT '0',
customid varchar(255) DEFAULT NULL,
title varchar(100) DEFAULT NULL,
PRIMARY KEY (stock_id),
UNIQUE KEY idx_products_id_stock_attributes (products_id,stock_attributes),
UNIQUE KEY idx_products_id_attributes_id (product_attribute_combo),
UNIQUE KEY idx_customid (customid)
);

to:

CREATE TABLE IF NOT EXISTS products_with_attributes_stock (
stock_id int(11) NOT NULL AUTO_INCREMENT,
products_id int(11) NOT NULL,
product_attribute_combo varchar(255) DEFAULT NULL,
stock_attributes varchar(190) NOT NULL,
quantity float NOT NULL DEFAULT '0',
sort int(11) NOT NULL DEFAULT '0',
customid varchar(255) DEFAULT NULL,
title varchar(100) DEFAULT NULL,
PRIMARY KEY (stock_id),
UNIQUE KEY idx_products_id_stock_attributes (products_id,stock_attributes),
UNIQUE KEY idx_products_id_attributes_id (product_attribute_combo),
UNIQUE KEY idx_customid (customid)
);


Now, that does have a potential impact on the combination(s) of attributes as the code is currently written.  The number (integer) that is generated for each option name/option value combination is stored as text and when more than one such attribute is identified then the next pair is also stored with a comma between.  Therefore if an attribute_id were to approach the "upper" limit of 2147483647 or 4294967295 (if the number is stored unsigned) then that one attribute alone takes 10 characters adding an additional attribute would take an additional 11 characters for each additional attribute (comma plus up to 10 characters), therefore the maximum limit in the database scheme applied above would be to have a maximum of 17 attributes for a single variant.  That also said, that's considered way more than necessary and/or ever suggested for any product. 

To further the database creation with possibility of utf8mb4 being used would be to reduce the other varchar(255) identifiers down to 191 instead, possibly... I've done some reading and can't recall if the 191 limit is specific to keys or to individual fields as well, but either way it seems like that's more than enough room for anything needed. :)

Please advise if the above minor change is successful so that it can be incorporated into the distribution.

The other "trial-and-error" approach would be to remove the unique key declarations, attempt to install, if successful, remove the install, then add one of the unique key designations in, install and repeat as necessary until it fails.  Then if it fails on the last addition again remove the other unique key designators except for the last added and try again, should fail at that point again and would require applying changes like described above.


On another "side" note, if not mistaken debug backtrace (or a slightly modified version) is already incorporated into ZC 1.5.5 so it does not need to be specifically installed.
31 Jan 2018, 7:04 PM
#2879
tmpinsnty avatar

tmpinsnty

New Zenner

Join Date:
Jun 2016
Location:
Minneapolis, MN
Posts:
37
Plugin Contributions:
0

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

First of all, thank you so much for all the hard work in creating this plugin. And thank you for the help here and in other places.

So I changed to varchar amount to 190 -> didn't work
removed all three unique ids and installing worked.
Adding any one back cause the error.

Should I just take off the unique or give up the this mod? I think I want it because I can 'turn off' my attribute status when we are out of stock of one size/color. Instead of deleting the attribute and then having to re-add it (plus remembering to add the up-charges) is silly. I thought I added an older version or the code someone put in that allowed an attribute_status field. It didn't actually work quite right, but I was able to but the attribute_status = 0 in the database and that works.

It's a would be nice but not it's not like I HAVE to have it.

M

31 Jan 2018, 7:37 PM
#2880
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

tmpinsnty:

First of all, thank you so much for all the hard work in creating this plugin. And thank you for the help here and in other places.

So I changed to varchar amount to 190 -> didn't work
removed all three unique ids and installing worked.
Adding any one back cause the error.

Should I just take off the unique or give up the this mod? I think I want it because I can 'turn off' my attribute status when we are out of stock of one size/color. Instead of deleting the attribute and then having to re-add it (plus remembering to add the up-charges) is silly. I thought I added an older version or the code someone put in that allowed an attribute_status field. It didn't actually work quite right, but I was able to but the attribute_status = 0 in the database and that works.

It's a would be nice but not it's not like I HAVE to have it.

M

Technically, it seems that could do without any of the additional unique keys, though I can't remember if there is an internal test/check to see if a custom id is entered as a unique value which from your described usage is likely not to be a problem. There's a plan to incorporate such an independent check/test, but it hasn't been a priority (yet).

So you could continue to operate the software without those three unique key entries, though it looks like a little could be done in the admin processing to test for and insert new items with consideration of allowing/rejecting duplicates meaning there may be a few operations of insertion that do not quite as cleanly prevent creating duplicate variant entries/stock increases, but this is not something that can't be through. There are multiple sensical ways to update particular records/entries and maintain operation.

I did a cursory review to see if customid as a key is essential or what effect it would have. The only thing I see is that without that table definition, then it is possible to enter the same customid for two different records. This may be desirable for some, it may not be for others. Maintaining unique customids otherwise would require a little bit of code to check for the existence and if present to prevent. The biggest obstacle is in attempting to come out of a duplicate customid condition to a unique customid condition in a way that makes sense to the user.

If anything it identifies that perhaps there are some originally builtin and until now functional considerations that if they are to remain a part of the code need to be handled in a different way that is more software driven rather than database structure driven.

So, I don't see any immediate operational issue with not using the additional three unique keys. When the appropriate duplication checking area(s) have been updated will post something here so that the change(s) can be incorporated and restore "normal" operation. :)