Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

    Quote Originally Posted by marton_1 View Post
    It looks like this,

    Code:
    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):

    Code:
     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...

  2. #12
    Join Date
    Apr 2013
    Location
    eglisau switzerland
    Posts
    567
    Plugin Contributions
    0

    Default Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

    Quote Originally Posted by mc12345678 View Post
    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):

    Code:
     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
    Attached Images Attached Images  

  3. #13
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

    Quote Originally Posted by marton_1 View Post
    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:
    Code:
                $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...

  4. #14
    Join Date
    Apr 2013
    Location
    eglisau switzerland
    Posts
    567
    Plugin Contributions
    0

    Default Re: Edit Attributes gives ERR_TOO_MANY_REDIRECTS error

    Quote Originally Posted by mc12345678 View Post
    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:
    Code:
                $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.
    Code:
    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.
    Code:
    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)
    Code:
    [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;

    Code:
    // 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;

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. ERR_Too_Many_Redirects using Ceon URI Mapping
    By MikeyG in forum General Questions
    Replies: 28
    Last Post: 25 May 2017, 07:51 PM
  2. Preview button gives error message.
    By Kalcat in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 20 Apr 2010, 07:46 PM
  3. Help! Add to cart gives error...
    By srt9969 in forum General Questions
    Replies: 0
    Last Post: 17 Mar 2009, 02:31 PM
  4. Adding attributes as dropdown gives radio buttons
    By marksu in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 24 Nov 2007, 01:29 PM
  5. Click on Product gives 404 Error
    By apster in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 27 May 2007, 05:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR