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: 660,384

Results 3,481 to 3,500 of 3,609
12 Feb 2023, 3:27 PM
#3481
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

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

I did a careful removal - checking after each set of files and it looks like the culprit is autoloader/config.products_with_attributes_stock.php

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

12 Feb 2023, 5:40 PM
#3482
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

delia:

my apologies if you've already addressed this but it's so basic. After uploading files, the catalog still works but the admin is showing a 500 error. Now granted this server is driving me crazy and this might not be typical but there is no error log to track this. v1.5.8, php 8.1

delia:

I did a careful removal - checking after each set of files and it looks like the culprit is autoloader/config.products_with_attributes_stock.php

In another thread you discussed the issue about this server responding with a 500 error when just loading the Zen Cart 1.5.8 files from a zip file. At the moment I don't recall whether that zip file was of your own making/revision or straight from the Zen Cart source. Then from what had been posted about this issue, I can't tell if changes made to support Zen Cart 1.5.8 class member inheritance have been incorporated or how against which github commit the fileset was obtained.

Basically, at the moment, unable to reproduce the issue. If server logs are not generated for you to see, would suggest contacting the host to gain more information. Removal of the autoloader file will prevent various operations, if all other files are present other than that one, I would suggest working within the file to remove actions starting at the back of the file.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

12 Feb 2023, 6:43 PM
#3483
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

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

The problem appeared to be the zip files before - the server is screwing up the extraction of them, leading to the initial problems. I simply uploaded the files for this. There is no "hosting" as it's an owner managed server. And everything else is working fine (a few mods installed). I did remove all other files before the autoloader - it was the last one and why I mentioned it.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

13 Feb 2023, 2:13 AM
#3484
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

delia:

The problem appeared to be the zip files before - the server is screwing up the extraction of them, leading to the initial problems. I simply uploaded the files for this. There is no "hosting" as it's an owner managed server. And everything else is working fine (a few mods installed). I did remove all other files before the autoloader - it was the last one and why I mentioned it.

Well, if the autoloader file truly was the last of the plugin to be removed, I am not surprised by site start issues. The autoloader really doesn't do anything other than identify what file(s) to load and in what order. Because most files in an autoloader are before error handling is fully in place, loading may stop with an onscreen message, but little else. Would have to enable debugging to see at what autoloader condition was last met.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

18 Feb 2023, 1:53 PM
#3485
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

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

So I installed it on a php 8.1 default site on my hosting. First was a mangled IS_ADMIN_FLAG statement in the admin lang.reg_ddsba.php. My fix was just to remove the whole statement. No other problems detected so far.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

19 Feb 2023, 11:31 AM
#3486
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

delia:

So I installed it on a php 8.1 default site on my hosting. First was a mangled IS_ADMIN_FLAG statement in the admin lang.reg_ddsba.php. My fix was just to remove the whole statement. No other problems detected so far.

Assuming that the "older" language files weren't also on the server? I've applied a commit to correct the error generated in converting the files. That patch can be found at: https://github.com/mc12345678/Stock_By_Attributes_Combined/pull/107/files

The only change applicable to this issue is in the first few lines of each language file.

While that code section isn't "necessary" for operation, it is included to try not to cause issues if the software is loaded to a different system or if attempted to be executed without having stated Zen Cart for further processing.

Thank you for reporting this issue!

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

20 Feb 2023, 4:03 PM
#3487
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

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

mc12345678:

First commit pushed. Able to add product to the cart.

I could not find that commit.
Can you possibly share the link?

20 Feb 2023, 7:15 PM
#3488
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

zamzom:

I could not find that commit.
Can you possibly share the link?
The specific commit that added back functionality is: Restore ZC1.5.8 functionality accessing protected members · mc12345678/Stock_By_Attributes_Combined@083359b (github.com)

However, there have been other improvements along the Zen Cart 1.5.8 consideration with commits made along the master path and the intention of not purposefully disabling older systems.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Feb 2023, 10:22 PM
#3489
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

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

Trying to run SBA 1.5.4 for [ZC 1.5.8][PHP 8.0]
Few remarks for some errors in admin/products_with_attributes_stock page.

First it gives the following error
--> PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 0, 1' at line 1

In admin/includes/classes/products_with_attributes_stock.php
on around line 376:

        $query_products =    "SELECT DISTINCT " . $retFieldsTxt . ((empty($search_order_by_fields) || empty($retFieldsTxt)) ? '' : ', ') . $search_order_by_fields . " 
          FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
          INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pa.products_id = pd.products_id)
          INNER JOIN " . TABLE_PRODUCTS . " p ON (pa.products_id = p.products_id)
          WHERE 
          pd.language_id=" . (int)$language_id . "
          " . $w . "
          ORDER BY " . $search_order_by;
//        . $SearchRange;      // zamzom: Took it out, because splitPageResults adds another LIMIT which triggers MySql error

        if (!isset($_GET['seachPID']) && !isset($_GET['pwas-search-button']) && !isset($_GET['updateReturnedPID'])) {
          $products_split = new splitPageResults($_GET['page'], STOCK_SET_SBA_NUMRECORDS, $query_products, $products_query_numrows);
        }

$SearchRange already carries a MySql LIMIT statement, however a consequtively coming call to splitPageResults adds another LIMIT statement so this triggers an error. I think the first $SearchRange can be ommited?

Secondly, search does not function. It seems earlier search parameter was input through a Get statement (in admin/products_with_attributes_stock.php) however in the latest it was converted to a Post method. Nevertheless again in admin/includes/classes/products_with_attributes_stock.php around line 277

        if (isset($_GET['search']) && $_GET['search']) { // mc12345678 Why was $_GET['search'] omitted?
            $s = zen_db_input($_GET['search']);
           //$w = "(p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '%$s%') AND  " ;//original version of search
            //$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '$s%' ) AND  " ;//changed search to products_model 'startes with'.
           //$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' ) AND  " ;//removed products_model from search
            $w = " AND ( p.products_id = '$s' 
                        OR d.products_name LIKE '%$s%' 
                        OR p.products_model LIKE '%$s%' 
                        OR p.products_id 
                IN (SELECT products_id 
                      FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                      WHERE pwas.customid
                        LIKE '%$s%')
                        ) "; //changed search to products_model 'starts with'.
        }

        //Show last edited record or Limit number of records displayed on page
        $SearchRange = null;
        if (isset($ReturnedProductID) && !isset($_GET['search'])) {
          $ReturnedProductID = zen_db_input($ReturnedProductID);
          //$w = "( p.products_id = '$ReturnedProductID' ) AND  " ;//sets returned record to display
          $w = " AND ( p.products_id = '$ReturnedProductID' ) " ;//sets returned record to display
          if (empty($_GET['products_filter']) || $_GET['products_filter'] < 0) {
            $SearchRange = "LIMIT 1";//show only selected record
          }

Get statements are used and these don't get anything :no: I think all of the $_GET['search'] should be replaced by $_POST['search']
also there is an error with the $w assignment, the tag for product description table should be pd instead of d, again around line 282:

            $w = " AND ( p.products_id = '$s' 
                        OR pd.products_name LIKE '%$s%' 
                        OR p.products_model LIKE '%$s%' 
                        OR p.products_id 
                IN (SELECT products_id 
                      FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                      WHERE pwas.customid
                        LIKE '%$s%')
                        ) "; //changed search to products_model 'starts with'.
23 Feb 2023, 10:32 PM
#3490
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

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

Trying to run SBA 1.5.4 for [ZC 1.5.8][PHP 8.0]
Few remarks for some errors in admin/products_with_attributes_stock page.

First it gives the following error
--> PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 0, 1' at line 1

In admin/includes/classes/products_with_attributes_stock.php
on around line 376:

        $query_products =    "SELECT DISTINCT " . $retFieldsTxt . ((empty($search_order_by_fields) || empty($retFieldsTxt)) ? '' : ', ') . $search_order_by_fields . " 
          FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
          INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pa.products_id = pd.products_id)
          INNER JOIN " . TABLE_PRODUCTS . " p ON (pa.products_id = p.products_id)
          WHERE 
          pd.language_id=" . (int)$language_id . "
          " . $w . "
          ORDER BY " . $search_order_by;
//        . $SearchRange;      // zamzom: Took it out, because splitPageResults adds another LIMIT which triggers MySql error

        if (!isset($_GET['seachPID']) && !isset($_GET['pwas-search-button']) && !isset($_GET['updateReturnedPID'])) {
          $products_split = new splitPageResults($_GET['page'], STOCK_SET_SBA_NUMRECORDS, $query_products, $products_query_numrows);
        }

$SearchRange already carries a MySql LIMIT statement, however a consequtively coming call to splitPageResults adds another LIMIT statement so this triggers an error. I think the first $SearchRange can be ommited?

23 Feb 2023, 10:34 PM
#3491
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

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

Secondly, search does not function. It seems earlier search parameter was input through a Get statement (in admin/products_with_attributes_stock.php) however in the latest it was converted to a Post method. Nevertheless again in admin/includes/classes/products_with_attributes_stock.php around line 277

        if (isset($_GET['search']) && $_GET['search']) { // mc12345678 Why was $_GET['search'] omitted?
            $s = zen_db_input($_GET['search']);
           //$w = "(p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '%$s%') AND  " ;//original version of search
            //$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '$s%' ) AND  " ;//changed search to products_model 'startes with'.
           //$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' ) AND  " ;//removed products_model from search
            $w = " AND ( p.products_id = '$s' 
                        OR d.products_name LIKE '%$s%' 
                        OR p.products_model LIKE '%$s%' 
                        OR p.products_id 
                IN (SELECT products_id 
                      FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                      WHERE pwas.customid
                        LIKE '%$s%')
                        ) "; //changed search to products_model 'starts with'.
        }

        //Show last edited record or Limit number of records displayed on page
        $SearchRange = null;
        if (isset($ReturnedProductID) && !isset($_GET['search'])) {
          $ReturnedProductID = zen_db_input($ReturnedProductID);
          //$w = "( p.products_id = '$ReturnedProductID' ) AND  " ;//sets returned record to display
          $w = " AND ( p.products_id = '$ReturnedProductID' ) " ;//sets returned record to display
          if (empty($_GET['products_filter']) || $_GET['products_filter'] < 0) {
            $SearchRange = "LIMIT 1";//show only selected record
          }

Get statements are used and these don't get anything :no: I think all of the $_GET['search'] should be replaced by $_POST['search']
also there is an error with the $w assignment, the tag for product description table should be pd instead of d, again around line 282:

            $w = " AND ( p.products_id = '$s' 
                        OR pd.products_name LIKE '%$s%' 
                        OR p.products_model LIKE '%$s%' 
                        OR p.products_id 
                IN (SELECT products_id 
                      FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                      WHERE pwas.customid
                        LIKE '%$s%')
                        ) "; //changed search to products_model 'starts with'.

cheers,

23 Feb 2023, 10:35 PM
#3492
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

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

Secondly, search does not function. It seems earlier search parameter was input through a Get statement (in admin/products_with_attributes_stock.php) however in the latest it was converted to a Post method. Nevertheless again in admin/includes/classes/products_with_attributes_stock.php around line 277

        if (isset($_GET['search']) && $_GET['search']) { // mc12345678 Why was $_GET['search'] omitted?
            $s = zen_db_input($_GET['search']);
           //$w = "(p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '%$s%') AND  " ;//original version of search
            //$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '$s%' ) AND  " ;//changed search to products_model 'startes with'.
           //$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' ) AND  " ;//removed products_model from search
            $w = " AND ( p.products_id = '$s' 
                        OR d.products_name LIKE '%$s%' 
                        OR p.products_model LIKE '%$s%' 
                        OR p.products_id 
                IN (SELECT products_id 
                      FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                      WHERE pwas.customid
                        LIKE '%$s%')
                        ) "; //changed search to products_model 'starts with'.
        }

        //Show last edited record or Limit number of records displayed on page
        $SearchRange = null;
        if (isset($ReturnedProductID) && !isset($_GET['search'])) {
          $ReturnedProductID = zen_db_input($ReturnedProductID);
          //$w = "( p.products_id = '$ReturnedProductID' ) AND  " ;//sets returned record to display
          $w = " AND ( p.products_id = '$ReturnedProductID' ) " ;//sets returned record to display
          if (empty($_GET['products_filter']) || $_GET['products_filter'] < 0) {
            $SearchRange = "LIMIT 1";//show only selected record
          }

Get statements are used and these don't get anything :no: I think all of the $_GET['search'] should be replaced by $_POST['search']

23 Feb 2023, 10:36 PM
#3493
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

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

Also, there is an error with the $w assignment, the tag for product description table should be pd instead of d, again around line 282:

            $w = " AND ( p.products_id = '$s' 
                        OR pd.products_name LIKE '%$s%' 
                        OR p.products_model LIKE '%$s%' 
                        OR p.products_id 
                IN (SELECT products_id 
                      FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                      WHERE pwas.customid
                        LIKE '%$s%')
                        ) "; //changed search to products_model 'starts with'.
27 Feb 2023, 1:45 PM
#3494
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

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

1.5.8 php 8.1

found another issue in extra cart actions > stock_by_attributes.php. Very few products on that site are using SBA so no actual knowledge if it's working.

#0 /includes/extra_cart_actions/stock_by_attributes.php(387): zen_debug_error_handler()
#1 /includes/main_cart_actions.php(30): include('/home/xxxxx...')
#2 /includes/init_includes/init_cart_handler.php(42): require('/home/xxx...')
#3 /includes/autoload_func.php(40): require_once('/home/xxxx...')
#4 /includes/application_top.php(237): require('/home/xxxx...')
#5 /index.php(25): require('/home/xxx...')
--> PHP Warning: Undefined array key "products_id" in /includes/extra_cart_actions/stock_by_attributes.php on line 387.

[27-Feb-2023 07:45:10 America/New_York] PHP Fatal error: Uncaught TypeError: zen_get_prid(): Argument #1 ($uprid) must be of type string, null given, called in /includes/extra_cart_actions/stock_by_attributes.php on line 387 and defined in /includes/functions/functions_products.php:429
Stack trace:
#0 /includes/extra_cart_actions/stock_by_attributes.php(387): zen_get_prid(NULL)
#1 /includes/main_cart_actions.php(30): include('/home/xxxx...')
#2 /includes/init_includes/init_cart_handler.php(42): require('/home/xxxx...')
#3 /includes/autoload_func.php(40): require_once('/home/xxxx...')
#4 /includes/application_top.php(237): require('/home/xxxx...')
#5 /index.php(25): require('/home/xxxx...')
#6 {main}
thrown in /includes/functions/functions_products.php on line 429

[27-Feb-2023 07:45:10 America/New_York] Request URI: /feeding-bees-c-90/global-pollen-patties-10-pk-p-316.html?action=add_product, IP address: 172.100.64.238
--> PHP Fatal error: Uncaught TypeError: zen_get_prid(): Argument #1 ($uprid) must be of type string, null given, called in /includes/extra_cart_actions/stock_by_attributes.php on line 387 and defined in /includes/functions/functions_products.php:429
Stack trace:
#0 /includes/extra_cart_actions/stock_by_attributes.php(387): zen_get_prid(NULL)
#1 /includes/main_cart_actions.php(30): include('/home/xxxxx...')
#2 /includes/init_includes/init_cart_handler.php(42): require('/home/xxxx...')
#3 /includes/autoload_func.php(40): require_once('/home/xxxx...')
#4 /includes/application_top.php(237): require('/home/humblexxxabo...')
#5 /index.php(25): require('/home/xxx...')
#6 {main}
thrown in /includes/functions/functions_products.php on line 429.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

28 Feb 2023, 9:00 AM
#3495
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

delia:

1.5.8 php 8.1

found another issue in extra cart actions > stock_by_attributes.php. Very few products on that site are using SBA so no actual knowledge if it's working.

#0 /includes/extra_cart_actions/stock_by_attributes.php(387): zen_debug_error_handler()
#1 /includes/main_cart_actions.php(30): include('/home/xxxxx...')
#2 /includes/init_includes/init_cart_handler.php(42): require('/home/xxx...')
#3 /includes/autoload_func.php(40): require_once('/home/xxxx...')
#4 /includes/application_top.php(237): require('/home/xxxx...')
#5 /index.php(25): require('/home/xxx...')
--> PHP Warning: Undefined array key "products_id" in /includes/extra_cart_actions/stock_by_attributes.php on line 387.

[27-Feb-2023 07:45:10 America/New_York] PHP Fatal error: Uncaught TypeError: zen_get_prid(): Argument #1 ($uprid) must be of type string, null given, called in /includes/extra_cart_actions/stock_by_attributes.php on line 387 and defined in /includes/functions/functions_products.php:429
Stack trace:
#0 /includes/extra_cart_actions/stock_by_attributes.php(387): zen_get_prid(NULL)
#1 /includes/main_cart_actions.php(30): include('/home/xxxx...')
#2 /includes/init_includes/init_cart_handler.php(42): require('/home/xxxx...')
#3 /includes/autoload_func.php(40): require_once('/home/xxxx...')
#4 /includes/application_top.php(237): require('/home/xxxx...')
#5 /index.php(25): require('/home/xxxx...')
#6 {main}
thrown in /includes/functions/functions_products.php on line 429

[27-Feb-2023 07:45:10 America/New_York] Request URI: /feeding-bees-c-90/global-pollen-patties-10-pk-p-316.html?action=add_product, IP address: 172.100.64.238
--> PHP Fatal error: Uncaught TypeError: zen_get_prid(): Argument #1 ($uprid) must be of type string, null given, called in /includes/extra_cart_actions/stock_by_attributes.php on line 387 and defined in /includes/functions/functions_products.php:429
Stack trace:
#0 /includes/extra_cart_actions/stock_by_attributes.php(387): zen_get_prid(NULL)
#1 /includes/main_cart_actions.php(30): include('/home/xxxxx...')
#2 /includes/init_includes/init_cart_handler.php(42): require('/home/xxxx...')
#3 /includes/autoload_func.php(40): require_once('/home/xxxx...')
#4 /includes/application_top.php(237): require('/home/humblexxxabo...')
#5 /index.php(25): require('/home/xxx...')
#6 {main}
thrown in /includes/functions/functions_products.php on line 429.


While there is obviously an opportunity to improve, any indication as to why the above page submit to add a product to the cart was missing the post data to identify the product in question? I.e., how to recreate the issue consistently? 

I've been able to duplicate the other recently identified issues and have found a few in resolution, but $_POST['products_id'] being null on submit of adding a product, just doesn't look out-of-the-box (unaltered) possible. I'm almost debating whether this should be addressed stepwise through the file or if execution of the file should terminate early. 

I mean casting the value to a string will result in null becoming a set of empty quotes which in turn will become a zero ultimately which is a product designation which is not supposed to exist and cause its own handled "issues", but what is it about 1.5.8 that introduced that null value? 

Again, I otherwise know how to cause that issue and why it needs to be addressed, but the way I perceive creating that condition is by me maliciously doing so.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Feb 2023, 3:47 PM
#3496
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

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

This has been a messy site - they've posted a message on the home page to call for orders even though the site is not in maintenance and there's tons of error messages for warnings for the fedex module - so hard to see how often this has happened. I've asked them to do some testing but I'm not sure that's happened to the extent it should and I had a hospital stay last week. You want access? I'm fine with you looking if you want.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

2 Mar 2023, 7:47 AM
#3497
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

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

[ZC 1.5.8][PHP 8.0]

Also, again on Products with Attributes Stock page in the admin, when you try to add a Description to a product variant there is this error:

PHP Fatal error: Uncaught Error: Call to protected method queryFactory::getBindVarValue() from scope products_with_attributes_stock in C:\xampp\htdocs\admin\includes\classes\products_with_attributes_stock.php:935

getBindVarValue is a protected method in QueryFactory class (around 525):

    protected function getBindVarValue($value, string $type)
    {

Any ideas how to overcome this?


PS to moderator:
Thinking that my earlier message submit did not go thru (I was oddly returned to the start page), I have divided it into segments and reposted. However after a while the initial message (#3489) appeared and now there are many repetitious messages.
Can the moderator so kindly remove my messages #3490 thru #3493. Please let #3489 stay.

2 Mar 2023, 11:49 AM
#3498
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

zamzom:

Trying to run SBA 1.5.4 for [ZC 1.5.8][PHP 8.0]
Few remarks for some errors in admin/products_with_attributes_stock page.

First it gives the following error
--> PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 0, 1' at line 1

In admin/includes/classes/products_with_attributes_stock.php
on around line 376:

    $query_products =    "SELECT DISTINCT " . $retFieldsTxt . ((empty($search_order_by_fields) || empty($retFieldsTxt)) ? '' : ', ') . $search_order_by_fields . " 
      FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa 
      INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pa.products_id = pd.products_id)
      INNER JOIN " . TABLE_PRODUCTS . " p ON (pa.products_id = p.products_id)
      WHERE 
      pd.language_id=" . (int)$language_id . "
      " . $w . "
      ORDER BY " . $search_order_by;

// . $SearchRange; // zamzom: Took it out, because splitPageResults adds another LIMIT which triggers MySql error

    if (!isset($_GET['seachPID']) && !isset($_GET['pwas-search-button']) && !isset($_GET['updateReturnedPID'])) {
      $products_split = new splitPageResults($_GET['page'], STOCK_SET_SBA_NUMRECORDS, $query_products, $products_query_numrows);
    }
> $SearchRange already carries a MySql LIMIT statement, however a consequtively coming call to splitPageResults adds another LIMIT statement so this triggers an error. I think the first $SearchRange can be ommited?
> 
> Secondly, search does not function. It seems earlier search parameter was input through a Get statement (in admin/products_with_attributes_stock.php) however in the latest it was converted to a Post method. Nevertheless again in admin/includes/classes/products_with_attributes_stock.php around line 277
> ```php
        if (isset($_GET['search']) && $_GET['search']) { // mc12345678 Why was $_GET['search'] omitted?
            $s = zen_db_input($_GET['search']);
           //$w = "(p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '%$s%') AND  " ;//original version of search
            //$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '$s%' ) AND  " ;//changed search to products_model 'startes with'.
           //$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' ) AND  " ;//removed products_model from search
            $w = " AND ( p.products_id = '$s' 
                        OR d.products_name LIKE '%$s%' 
                        OR p.products_model LIKE '%$s%' 
                        OR p.products_id 
                IN (SELECT products_id 
                      FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                      WHERE pwas.customid
                        LIKE '%$s%')
                        ) "; //changed search to products_model 'starts with'.
        }

        //Show last edited record or Limit number of records displayed on page
        $SearchRange = null;
        if (isset($ReturnedProductID) && !isset($_GET['search'])) {
          $ReturnedProductID = zen_db_input($ReturnedProductID);
          //$w = "( p.products_id = '$ReturnedProductID' ) AND  " ;//sets returned record to display
          $w = " AND ( p.products_id = '$ReturnedProductID' ) " ;//sets returned record to display
          if (empty($_GET['products_filter']) || $_GET['products_filter'] < 0) {
            $SearchRange = "LIMIT 1";//show only selected record
          }

Get statements are used and these don't get anything :no: I think all of the $_GET['search'] should be replaced by $_POST['search']
also there is an error with the $w assignment, the tag for product description table should be pd instead of d, again around line 282:

        $w = " AND ( p.products_id = '$s' 
                    OR pd.products_name LIKE '%$s%' 
                    OR p.products_model LIKE '%$s%' 
                    OR p.products_id 
            IN (SELECT products_id 
                  FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                  WHERE pwas.customid
                    LIKE '%$s%')
                    ) "; //changed search to products_model 'starts with'.
Please note, I am not necessarily responding to the "latest" or one that has the "most detail". Please forgive me as it looks like 6 posts were made to say the same thing, with this first one effectively addressing all of the issues at once. I'm ok with responding to the entirety.

Fatal error because of the changes made to the splitPageResults class, I'm addressing that by evaluating the constructor for the class to determine how to respond. In Zen Cart 1.5.7 and below, any such "LIMIT" statement was basically removed/ignored. I haven't gone back through all of the code to see if the use of LIMIT is at all necessary, but at one time it was and so I'm keeping its potential for existence in "older" versions, but removing it from queries that are directly fed into the splitPageResults query basically of Zen Cart 1.5.8.

Then, the search feature. Kind of funny, I think that I vaguely recall noticing that "recently" the search really only worked by selection of product from the various dropdowns. No one has said anything in the last 3 years since that change was made. Too bad really. Lack of statement of that issue has a lot of meanings. I thank you for pointing it out and therefore driving for solution. So, what I did instead of modifying the $_GET to $_POST was to instead assign the $_GET to the $_POST. In all cases when both are available, POST should override GET for security purposes. That is now done here as well with the search.

The table prefix of 'd' for product description? Unfortunately that was how we had been referencing the products_description table. At one point or another, effort was made to align the table references with those "standard" in Zen Cart, even if that itself is not consistent. I've updated references.

Then, because of discrepancies in how Zen Cart has handled strings containing NULL, code that has been incorporated uses a method of the query_factory that in Zen Cart 1.5.8 has become protected. Yes, the same result could have been obtained using what is now a public method; however, at the time of incorporation I specifically chose to use the unique method (getBindVarValue) instead of the method that was perceived as malleable and basically required a dummy value to perform the test directly accomplished by getBindVarValue.

BTW, thank you for the explanation of why the previous posts were made first as a single and applicable post and then split up. Although you've requested the other posts to be deleted, I wouldn't be surprised if they remain. There's no telling if or how many of them already have been referenced elsewhere on the internet. No harm though in them remaining either. :)

As to solution, I didn't yet pretty up the commits, but if you grab the code from this branch/commit, it addresses the items you've identified and others that were identified while addressing them: <https://github.com/mc12345678/Stock_By_Attributes_Combined/commit/19ea27f4ac8334a4b4c61569d77461d52e940d29>

I'm still working through what was recently otherwise posted and doing a comparison against the Zen Cart 1.5.8 version of the shopping cart class to address improvements to the extra_cart_actions file.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

5 Mar 2023, 1:05 PM
#3499
zamzom avatar

zamzom

New Zenner

Join Date:
Jun 2009
Location:
Europe
Posts:
60
Plugin Contributions:
0

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

So far so good.
Thank you mc12345678 for your quick attention and neat corrections.
I will keep reporting other issues when I come accross.

Few more things I recently encountered:
Now, the search functions in the admin/products_with_attributes_stock page. However, if the search results are more than one page, next page button does not work. It takes you to the full list of products' second page. I coudn't go into the reason of that because I have more important issues I have to fix first, but I am suspecting that it is due to POSTed values again.

Another thing I have noticed; SBA makes modifications in functions_lookups.php file in two functions:
zen_get_products_stock
zen_check_stock

/**
 * functions_lookups.php
 * Lookup Functions for various core activities related to countries, prices, products, product types, etc
 *
 * @package functions
 * @copyright Copyright 2003-2016 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: Author: mc12345678  Tue Feb 2 16:23:08 2016 -0500 Modified in v1.5.5 $
 * 
 * Stock by Attributes 1.5.4 15-12-21 mc12345678
 */

Nevertheless, it seems in ZC 1.5.8 these functions are moved into functions_products.php and a notifier mechanism is incorporated.
I wonder if these modifications can be carried there as is?

5 Mar 2023, 1:37 PM
#3500
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

zamzom:

So far so good.
Thank you mc12345678 for your quick attention and neat corrections.
I will keep reporting other issues when I come accross.

Few more things I recently encountered:
Now, the search functions in the admin/products_with_attributes_stock page. However, if the search results are more than one page, next page button does not work. It takes you to the full list of products' second page. I coudn't go into the reason of that because I have more important issues I have to fix first, but I am suspecting that it is due to POSTed values again.

Another thing I have noticed; SBA makes modifications in functions_lookups.php file in two functions:
zen_get_products_stock
zen_check_stock

/**

  • functions_lookups.php
  • Lookup Functions for various core activities related to countries, prices, products, product types, etc
  • @package functions
  • @copyright Copyright 2003-2016 Zen Cart Development Team
  • @copyright Portions Copyright 2003 osCommerce
  • @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  • @version $Id: Author: mc12345678 Tue Feb 2 16:23:08 2016 -0500 Modified in v1.5.5 $
  • Stock by Attributes 1.5.4 15-12-21 mc12345678
    */
> 
> Nevertheless, it seems in ZC 1.5.8 these functions are moved into functions_products.php and a notifier mechanism is incorporated.
> I wonder if these modifications can be carried there as is?

If installing to 1.5.8, there are no modifications to be made to that file, the only catalog file modifications are in template files. The observers have existed for those persons since Zen Cart 1.5.6 and such edit hasn't been necessary since then.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...