Forums / Setting Up Categories, Products, Attributes / Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

Views: 5,536

Results 1 to 14 of 14
29 May 2022, 9:33 PM
#1
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

[Note: remember to include site URL, ZC version, list of plugins, PHP version, etc ... read the Posting Tips shown above for information to include in your post here.
And, remove this comment before actually posting!]

29 May 2022, 9:42 PM
#2
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

Oooppps, try again
157b PHP 7.4
When I go to a product in Categories / Products, click on "attributes controller" then click on "edit attributes" I see this error.

Redirect checker tells me the 302 problem is in https://www.simmar.ch/catalog/ADMIN/index.php

Winmerge tells me my index.php is identical to the downloaded one.

I have cleared my caches.

Any suggestions?

29 May 2022, 10:13 PM
#3
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

marton_1:

Oooppps, try again
157b PHP 7.4
When I go to a product in Categories / Products, click on "attributes controller" then click on "edit attributes" I see this error.

Redirect checker tells me the 302 problem is in https://www.simmar.ch/catalog/ADMIN/index.php

Winmerge tells me my index.php is identical to the downloaded one.

I have cleared my caches.

Any suggestions?

Restarted my PC and the problem seems to have gone away. I will go and stand in the corner....

1 Jun 2022, 2:09 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

I don't recall if there were changes that affected that particular operation, but it still is highly suggested to upgrade to at least 1.5.7c of course 1.5.7d would be preferred... but there are/ were issues in 1.5.7b that are important to correct/ address.

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

6 Jun 2022, 1:15 PM
#5
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

Thanks for the advice, I was hoping for a simpler solution than upgrading zen cart. :)

Anyway I am getting the same problem again in Chrome and Microsoft Edge.
Rebooted my PC again and it did not help.

Only one Product Category shows this problem, the others are OK..
I tried the various solutions in the Web like ckearing cookies, cache and other stuff.

I ran the Kinsta redirect checker but I do not know what the result means, copy of the 302 result below, the 200 response is similar plus "X-Cache-Status MISS"

https://www.simmar.ch/catalog/ADMIN/index.php?cmd=attributes_controller&products_filter=0&current_category_id=148

Response headers
Server	nginx
Date	Mon, 06 Jun 2022 12:43:19 GMT
Content-Type	text/html; charset=utf-8
Content-Length	0
Connection	keep-alive
Vary	Accept-Encoding
Expires	Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control	no-store, no-cache, must-revalidate
Pragma	no-cache
Set-Cookie	zenAdminID=xxxxxx; path=/catalog/ADMIN; domain=.www.simmar.ch; secure; HttpOnly; SameSite=lax
Location	https://www.simmar.ch/catalog/ADMIN/index.php?cmd=login&camefrom=attributes_controller.php
X-Cache-Status	MISS
URL
https://www.simmar.ch/catalog/ADMIN/index.php?cmd=login&camefrom=attributes_controller.php
STATUS MESSAGE
OK
6 Jun 2022, 1:28 PM
#6
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

I added the redirect path Chrome extension which told me I got the following 24 times

https://www.simmar.ch/catalog/ADMIN/index.php?cmd=attributes_controller&products_filter=0¤t_category_id=148
302: Temporary redirect to https://www.simmar.ch/catalog/ADMIN/index.php?cmd=attributes_controller&products_filter=0¤t_category_id=148

Plus this detail

Server IP Address80.74.141.90
servernginx
dateMon, 06 Jun 2022 13:23:10 GMT
content-typetext/html; charset=utf-8
varyAccept-Encoding
expiresThu, 19 Nov 1981 08:52:00 GMT
cache-controlno-store, no-cache, must-revalidate
pragmano-cache
content-encodinggzip
locationhttps://www.simmar.ch/catalog/ADMIN/index.php?cmd=attributes_controller&products_filter=0¤t_category_id=148
x-cache-statusBYPASS
6 Jun 2022, 4:04 PM
#7
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

Don't redirect your admin pages.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

6 Jun 2022, 5:17 PM
#8
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

swguy:

Don't redirect your admin pages.

Thanks but I do not intentionally redirect them :)

I took another look at the code and the products filter field is zero, see bold.

https://www.simmar.ch/catalog/ADMIN/index.php?cmd=attributes_controller&[B]products_filter=0¤[/B]t_category_id=148
302: Temporary redirect to https://www.simmar.ch/catalog/ADMIN/index.php?cmd=attributes_controller&[B]products_filter=0¤t_[/B]category_id=148

When I look at one that works correctly then product filter has the product number, see bold.

https://www.simmar.ch/catalog/caNdy-shD-dArts/index.php?cmd=attributes_controller&[B]products_filter=2901[/B]¤t_category_id=159

The problem occurs when I click on "Edit Attribues", the good ones have an ID the bad ones no id, see pictures

6 Jun 2022, 9:14 PM
#9
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

When the product that is not working is displaying that "empty" area, what is the browser link? I assume that part of it reads: ?cmd=category_product_listing

What is the rest?

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

6 Jun 2022, 10:02 PM
#10
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

mc12345678:

When the product that is not working is displaying that "empty" area, what is the browser link? I assume that part of it reads: ?cmd=category_product_listing

What is the rest?

It looks like this,

https://www.simmar.ch/catalog/ADMIN/index.php?cmd=category_product_listing&cPath=74&pID=2337&action=attribute_features&page=2

2337 is the correct project id for this product, that is the bad one in my picture

7 Jun 2022, 4:59 AM
#11
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

marton_1:

It looks like this,

https://www.simmar.ch/catalog/ADMIN/index.php?cmd=category_product_listing&cPath=74&pID=2337&action=attribute_features&page=2

> 
> 2337 is the correct project id for this product, that is the bad one in my picture

From review of the core code or at least what would be expected of an up-to-date version, it appears that there is likely a "minor" database issue. Either that or an undeclared plugin is interfering. 

Basically it appears that there is not a product with category match in the products_to_categories table for products_id = 2337 for categories_id = 74. As a result, the products_id returned is 0 in a way.

I haven't done a lot of research on what is likely to happen in executing the following sql command (after backing up the database):

INSERT INTO products_to_categories (products_id,
categories_id) VALUES (2337,74);


What this should do if the above problem was present is that the first time it is executed you should get a notification of successfully completing one instruction. I suspect that if the record already exists either a 500 error will occur or some other sql error may occur. Looking at the resulting debug log would give the most information; however, would also be very telling if the first attempt to apply the above is successful. 

Note the above is written more with the intention of executing in the admin, tools, install sql patch area of the Zen Cart admin.

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

7 Jun 2022, 12:09 PM
#12
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

mc12345678:

From review of the core code or at least what would be expected of an up-to-date version, it appears that there is likely a "minor" database issue. Either that or an undeclared plugin is interfering.

Basically it appears that there is not a product with category match in the products_to_categories table for products_id = 2337 for categories_id = 74. As a result, the products_id returned is 0 in a way.

I haven't done a lot of research on what is likely to happen in executing the following sql command (after backing up the database):

INSERT INTO products_to_categories (products_id,
categories_id) VALUES (2337,74);

> 
> What this should do if the above problem was present is that the first time it is executed you should get a notification of successfully completing one instruction. I suspect that if the record already exists either a 500 error will occur or some other sql error may occur. Looking at the resulting debug log would give the most information; however, would also be very telling if the first attempt to apply the above is successful. 
> 
> Note the above is written more with the intention of executing in the admin, tools, install sql patch area of the Zen Cart admin.

Thank you for looking at this, instead of running your SQL code I looked in the products_to_categories table and found 2337 is linked to main category ID 163 and linked id 75, see picture.
Another product  is linked to main ID 163 and linked id 75 which works fine
9 Jun 2022, 1:22 AM
#13
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

marton_1:

Thank you for looking at this, instead of running your SQL code I looked in the products_to_categories table and found 2337 is linked to main category ID 163 and linked id 75, see picture.
Another product is linked to main ID 163 and linked id 75 which works fine

That certainly is a more tried and true method to evaluate the condition of the database. I will note that the above text content incorrectly states concern with categories_id 75 instead of 74 as shown in the image and previously referenced. Likely a keyboard slip and provides some useful information.

What the image indicates is that when the database is queried for products_id of 2337 that the category identified on the browser (74) has that product identified. This is important for the query that is generated at least in a default store which is something similar to the below:

            $products_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_quantity,                                          p.products_price, p.products_status, p.products_model, p.products_sort_order,
                                          p.master_categories_id";
            $products_query_raw .= $extra_select;


            $products_query_raw .= " FROM " . TABLE_PRODUCTS . " p";
            $products_query_raw .= $extra_from;


            $products_query_raw .= " LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pd.products_id = p.products_id)";
            $products_query_raw .= $extra_joins;


            $where = " WHERE pd.language_id = " . (int)$_SESSION['languages_id'];
            $where .= $extra_ands;


            if ($search_result && $action != 'edit_category') {
                $where .= "  AND (pd.products_name LIKE '%:search%'
                              OR pd.products_description LIKE '%:search%'
                              OR p.products_id = ':search'
                              OR p.products_model LIKE '%:search%'
                            ) ";
                $where = $db->bindVars($where, ':search', $_GET['search'], 'noquotestring');
            } else {
                $products_query_raw.= " LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ON (p2c.products_id = p.products_id) ";
                $where .= " AND p2c.categories_id=" . (int)$current_category_id;
            }


            $products_query_raw .= $where . $order_by;

Because the above browser path did not include search criteria, then the query ends with: " LEFT JOIN products_to_categories p2c ON (p2c.products_id = p.products_id) AND p2c.categories_id=74" So, having the above image associated with that database, if that database is really and truly the same one that is referenced by the store, it seems that perhaps there is some observer that is listening to the notifier in admin/category_product_listing.php and causing problem(s) described. The result appears to be that when the query is executed, $current_category_id is expected to be 74, $_SESSION['languages_id'] is expected to be 1, but could be whatever value that exists for the language(s) installed. Even then, it appears (I haven't run my own testing) that it could even basically be a non-existent language designation and still give expected results. Right now it is given a result of zero matching items, but even that doesn't seem right..

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

9 Jun 2022, 9:15 AM
#14
marton_1 avatar

marton_1

Totally Zenned

Join Date:
Apr 2013
Location:
eglisau switzerland
Posts:
568
Plugin Contributions:
0

Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

mc12345678:

That certainly is a more tried and true method to evaluate the condition of the database. I will note that the above text content incorrectly states concern with categories_id 75 instead of 74 as shown in the image and previously referenced. Likely a keyboard slip and provides some useful information.

What the image indicates is that when the database is queried for products_id of 2337 that the category identified on the browser (74) has that product identified. This is important for the query that is generated at least in a default store which is something similar to the below:

        $products_query_raw = "SELECT p.products_type, p.products_id, pd.products_name, p.products_quantity,                                          p.products_price, p.products_status, p.products_model, p.products_sort_order,
                                      p.master_categories_id";
        $products_query_raw .= $extra_select;


        $products_query_raw .= " FROM " . TABLE_PRODUCTS . " p";
        $products_query_raw .= $extra_from;


        $products_query_raw .= " LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pd.products_id = p.products_id)";
        $products_query_raw .= $extra_joins;


        $where = " WHERE pd.language_id = " . (int)$_SESSION['languages_id'];
        $where .= $extra_ands;


        if ($search_result && $action != 'edit_category') {
            $where .= "  AND (pd.products_name LIKE '%:search%'
                          OR pd.products_description LIKE '%:search%'
                          OR p.products_id = ':search'
                          OR p.products_model LIKE '%:search%'
                        ) ";
            $where = $db->bindVars($where, ':search', $_GET['search'], 'noquotestring');
        } else {
            $products_query_raw.= " LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ON (p2c.products_id = p.products_id) ";
            $where .= " AND p2c.categories_id=" . (int)$current_category_id;
        }


        $products_query_raw .= $where . $order_by;
> 
> Because the above browser path did not include search criteria, then the query ends with:  " LEFT JOIN products_to_categories p2c ON (p2c.products_id = p.products_id) AND p2c.categories_id=74" So, having the above image associated with that database, if that database is really and truly the same one that is referenced by the store, it seems that perhaps there is some observer that is listening to the notifier in admin/category_product_listing.php and causing problem(s) described. The result appears to be that when the query is executed, $current_category_id is expected to be 74, $_SESSION['languages_id'] is expected to be 1, but could be whatever value that exists for the language(s) installed. Even then, it appears (I haven't run my own testing) that it could even basically be a non-existent language designation and still give expected results. Right now it is given a result of zero matching items, but even that doesn't seem right..

Thank you for spending so much time on this :)

Apologies for my typo; 75 not 74 , fat fingers :)

For other products it works OK, like products_filter=2785&current_category_id=159 & products_filter=1654&current_category_id=146

I have a workaround when I enter the following into my browser when logged into admin for product 2337, id74 then I can edit my attributes OK.

https://www.simmar.ch/catalog/caNdy-shD-dArts/index.php?cmd=attributes_controller&products_filter=2337&current_category_id=74


If I use the linked id 163 in the following browser link then I can also edit my attributes OK.

https://www.simmar.ch/catalog/ADMIN/index.php?cmd=attributes_controller&products_filter=2337&current_category_id=163


I turned on the optional logging and got (multiple times)

[09-Jun-2022 10:59:56 Europe/Zurich] Request URI: /catalog/Admin/index.php?cmd=category_product_listing&cPath=163&pID=2337&action=attribute_features&page=2, IP address: 88.151.150.206
#1 require(/Admin/category_product_listing.php) called at [/ADMIN/index.php:11]
--> PHP Notice: Undefined variable: pInfo in /ADMIN/category_product_listing.php on line 960.

[09-Jun-2022 10:59:56 Europe/Zurich] Request URI: /ADMIN/index.php?cmd=category_product_listing&cPath=163&pID=2337&action=attribute_features&page=2, IP address: 88.151.150.206
#1 require(/ADMIN/category_product_listing.php) called at [/ADMIN/index.php:11]
--> PHP Notice: Trying to get property 'products_id' of non-object in /ADMIN/category_product_listing.php on line 960.


The ADMIN/category_product_listing.php on line 960 is the last line of code below;

// attribute features
case 'attribute_features':
$copy_attributes_delete_first = '0';
$copy_attributes_duplicates_skipped = '0';
$copy_attributes_duplicates_overwrite = '0';
$copy_attributes_include_downloads = '1';
$copy_attributes_include_filename = '1';
$heading[] = array('text' => '<h4>' . TEXT_INFO_HEADING_ATTRIBUTE_FEATURES . $pInfo->products_id . '</h4>');

        $contents[] = array('align' => 'center', 'text' => '<strong>' . TEXT_PRODUCTS_ATTRIBUTES_INFO . '</strong>');

        $contents[] = array('align' => 'center', 'text' => '<strong>' . zen_get_products_name($pInfo->products_id, $_SESSION['languages_id']) . ' ID# ' . $pInfo->products_id . '</strong>');
        $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, '&action=attributes_preview' . '&products_filter=' . $pInfo->products_id . '&current_category_id=' . $current_category_id) . '" class="btn btn-info" role="button">' . IMAGE_PREVIEW . '</a> <a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $pInfo->products_id . '&current_category_id=' . $current_category_id) . '" class="btn btn-primary" role="button">' . IMAGE_EDIT_ATTRIBUTES . '</a>');
        $contents[] = array('align' => 'left', 'text' => '<strong>' . TEXT_PRODUCT_ATTRIBUTES_DOWNLOADS . '</strong>' . zen_has_product_attributes_downloads($pInfo->products_id) . zen_has_product_attributes_downloads($pInfo->products_id, true));
        $contents[] = array('align' => 'left', 'text' => TEXT_INFO_ATTRIBUTES_FEATURES_DELETE . '<strong>' . zen_get_products_name($pInfo->products_id) . ' ID# ' . $pInfo->products_id . '</strong> <a href="' . zen_href_link(FILENAME_CATEGORY_PRODUCT_LISTING, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=delete_attributes' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . '&products_id=' . $pInfo->products_id) . '" class="btn btn-danger" role="button">' . IMAGE_DELETE . '</a>');
        $contents[] = array('align' => 'left', 'text' => TEXT_INFO_ATTRIBUTES_FEATURES_UPDATES . '<strong>' . zen_get_products_name($pInfo->products_id, $_SESSION['languages_id']) . ' ID# ' . $pInfo->products_id . '</strong> <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=update_attributes_sort_order' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . '&products_id=' . $pInfo->products_id) . '" class="btn btn-primary" role="button">' . IMAGE_UPDATE . '</a>');
        $contents[] = array('align' => 'left', 'text' => TEXT_INFO_ATTRIBUTES_FEATURES_COPY_TO_PRODUCT . '<strong>' . zen_get_products_name($pInfo->products_id, $_SESSION['languages_id']) . ' ID# ' . $pInfo->products_id . '</strong><a href="' . zen_href_link(FILENAME_CATEGORY_PRODUCT_LISTING, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=attribute_features_copy_to_product' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . '&products_id=' . $pInfo->products_id) . '" class="btn btn-primary" role="button">' . IMAGE_COPY_TO . '</a>');
        $contents[] = array('align' => 'left', 'text' => '<br>' . TEXT_INFO_ATTRIBUTES_FEATURES_COPY_TO_CATEGORY . '<strong>' . zen_get_products_name($pInfo->products_id, $_SESSION['languages_id']) . ' ID# ' . $pInfo->products_id . '</strong> <a href="' . zen_href_link(FILENAME_CATEGORY_PRODUCT_LISTING, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . '&action=attribute_features_copy_to_category' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . '&products_id=' . $pInfo->products_id) . '" class="btn btn-primary" role="button">' . IMAGE_COPY_TO . '</a>');
        $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_CATEGORY_PRODUCT_LISTING, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '" class="btn btn-default" role="button">' . IMAGE_CANCEL . '</a>');
        break;