Admin/vendor Products.update Page Gets Out Of Admin Panel

Hello All,

Why admin/vendor products.update page gets out of admin panel when saving, after 2 condition when product name change or product category change?

I have tested all variants to change price, code, description, or anything, everything works perfectly as expected. but when change product name or added another extra category, after it has saved on database, gets redirected to storefront, customer section/area.

I know this is not in default thing. I have some custom work with function fn_mycustom_update_product_post hook like this;

function fn_mycustom_update_product_post($product_data, $product_id, $lang_code, $create)
{
    if (AREA !== 'A') {
        return;
    }

// $_company_data = fn_get_company_data($product_data[‘company_id’]);
$_company_data = fn_get_company_by_product_id($product_id);
db_query(“UPDATE ?:products SET plan_id = ?i WHERE product_id = ?i”, $_company_data[‘plan_id’], $product_id);

}

I remember someone asked the exact same question couple years ago, but I couldn't find that topic now. for that reason I have opened another topic. Please help!

Please redirect me how to find where is the problem.

Thanks in advance!

Hello All,

Why admin/vendor products.update page gets out of admin panel when saving, after 2 condition when product name change or product category change?

I have tested all variants to change price, code, description, or anything, everything works perfectly as expected. but when change product name or added another extra category, after it has saved on database, gets redirected to storefront, customer section/area.

I know this is not in default thing. I have some custom work with function fn_mycustom_update_product_post hook like this;

function fn_mycustom_update_product_post($product_data, $product_id, $lang_code, $create)
{
    if (AREA !== 'A') {
        return;
    }

// $_company_data = fn_get_company_data($product_data[‘company_id’]);
$_company_data = fn_get_company_by_product_id($product_id);
db_query(“UPDATE ?:products SET plan_id = ?i WHERE product_id = ?i”, $_company_data[‘plan_id’], $product_id);

}

I remember someone asked the exact same question couple years ago, but I couldn't find that topic now. for that reason I have opened another topic. Please help!

Please redirect me how to find where is the problem.

Thanks in advance!

Hello!

This could be caused by the low value of max_input_vars , please contact your server administrator and ask him/her to increase this value to at least to 10000.

Please let me know if it helps.

Hello!

This could be caused by the low value of max_input_vars , please contact your server administrator and ask him/her to increase this value to at least to 10000.

Please let me know if it helps.

Hello, thanks for your reply.

No, it didn't help at all. default value was commented, which is default value 1000, I did uncomment it and increased to 10k and restarted server, but still the same.

then one by one disabled all addons to test which is related to product update and find out it's kind of related to only one addon. then used 'update_product_pre' to change the assign multiple category to my way worked as well. now only thing left is when change product name, after saving redirects to customer area.

but for 100% sure, nothing wrong on code, because I don't have anything custom related to change product name. but let me more deeply explain this;

when I change product name, it's first saves product_data and redirects to customer area. how do I know? after I click save button, right way I click stop button on chrome and refresh the page. I see green cs-cart message tells it's saved, I see it's already saved. then I check database manually, yes, it's saved. so, after saved, it's getting redirect to customer area. why?

whatever the problem is, after it's saved product_data into database, it's redirects to customer area.

from my learning/research, I can say, I don't know many thing about cs-cart's caching, session, AJAX, security. but it's saved to database, then what is has to do? it has to do redirect the same $product_id. if I change other anything(price, categories, description or whatever), it's normal, but only if I change product name, then the problem happens. what it could be?

I have used the //fn_set_hook('get_filters_products_count_pre', $params, $cache_params, $cache_tables); hook on my addon. then to test it, I have disabled this hook as well, but it's the same result.

one more thing I have noticed during my learning that, on some cs-cart's addons uses the addons parameters with the & sign, some of them not. for example function fn_ozemning_get_filters_products_count_pre(&$params, &$cache_params, &$cache_tables) I used with & sign on all 3 parameters. and the same thing I see different on even cs-cart's own addons. example bestsellers and seo both uses "get_products" hook and func.php file it's different passed the parameters on hook. some with & and some without the &.
if it's not problem(I have tested again, I don't see any problems there), then I can tell you there is nothing problem on code, because I don't have anything to change product name.
what could cause the problem?
Thanks in advance!

Hello, thanks for your reply.

No, it didn't help at all. default value was commented, which is default value 1000, I did uncomment it and increased to 10k and restarted server, but still the same.

then one by one disabled all addons to test which is related to product update and find out it's kind of related to only one addon. then used 'update_product_pre' to change the assign multiple category to my way worked as well. now only thing left is when change product name, after saving redirects to customer area.

but for 100% sure, nothing wrong on code, because I don't have anything custom related to change product name. but let me more deeply explain this;

when I change product name, it's first saves product_data and redirects to customer area. how do I know? after I click save button, right way I click stop button on chrome and refresh the page. I see green cs-cart message tells it's saved, I see it's already saved. then I check database manually, yes, it's saved. so, after saved, it's getting redirect to customer area. why?

whatever the problem is, after it's saved product_data into database, it's redirects to customer area.

from my learning/research, I can say, I don't know many thing about cs-cart's caching, session, AJAX, security. but it's saved to database, then what is has to do? it has to do redirect the same $product_id. if I change other anything(price, categories, description or whatever), it's normal, but only if I change product name, then the problem happens. what it could be?

I have used the //fn_set_hook('get_filters_products_count_pre', $params, $cache_params, $cache_tables); hook on my addon. then to test it, I have disabled this hook as well, but it's the same result.

one more thing I have noticed during my learning that, on some cs-cart's addons uses the addons parameters with the & sign, some of them not. for example function fn_ozemning_get_filters_products_count_pre(&$params, &$cache_params, &$cache_tables) I used with & sign on all 3 parameters. and the same thing I see different on even cs-cart's own addons. example bestsellers and seo both uses "get_products" hook and func.php file it's different passed the parameters on hook. some with & and some without the &.
if it's not problem(I have tested again, I don't see any problems there), then I can tell you there is nothing problem on code, because I don't have anything to change product name.
what could cause the problem?
Thanks in advance!

Unfortunately I have no guesses about this. Could you please contact us via Help Desk on this case, so that we will be able to examine this redirect directly in your installation?

As an alternative, since you are looking familiar with programming, you can print the backtrace in the fn_redirect function (located in the app/functions/fn.common.php file), to find out what is causing the redirect:

https://www.php.net/manual/en/function.debug-print-backtrace.php

As for the & sign, it is used to pass variable by reference:

https://www.php.net/manual/en/language.references.php

I hope it will help you.

Unfortunately I have no guesses about this. Could you please contact us via Help Desk on this case, so that we will be able to examine this redirect directly in your installation?

As an alternative, since you are looking familiar with programming, you can pring the backtrace in the fn_redirect function (located in the app/functions/fn.common.php file), to find out what is causing the redirect:

https://www.php.net/manual/en/function.debug-print-backtrace.php

As for the & sign, it is used to pass variable by reference:

https://www.php.net/manual/en/language.references.php

I hope it will help you.

Dear cs-cart team,

Thank you very much for your redirection. with your correct redirection, I could find what's the problem and fixed.

For users in future, I will write it here.

fn_redirect function also sets many changes in url. I had used my own 'url_set_locations' hook and it's rule was for mainly in customers area. and in my code, I used it depend on it's own &area and changed it to like below and it got fixed. but from this what can we learn is, for sure fn_product_update changes/does the product name and I did checked fn.products.php file code, indeed it's. for that reason this problem I have faced. but still I can't understand why? but it gave me idea and I did fixed.

//fn_set_hook('url_set_locations', $url, $area, $protocol, $lang_code, $locations);
//if($area != 'C'){
if (AREA != 'C') {
    return;
}
</pre>

Dear cs-cart team,

I am really appreciate you for this redirection. Please keep up your this type of really good support.

Thanks again!

Dear cs-cart team,

Thank you very much for your redirection. with your correct redirection, I could find what's the problem and fixed.

For users in future, I will write it here.

fn_redirect function also sets many changes in url. I had used my own 'url_set_locations' hook and it's rule was for mainly in customers area. and in my code, I used it depend on it's own &area and changed it to like below and it got fixed. but from this what can we learn is, for sure fn_product_update changes/does the product name and I did checked fn.products.php file code, indeed it's. for that reason this problem I have faced. but still I can't understand why? but it gave me idea and I did fixed.

//fn_set_hook('url_set_locations', $url, $area, $protocol, $lang_code, $locations);
//if($area != 'C'){
if (AREA != 'C') {
    return;
}
</pre>

Dear cs-cart team,

I am really appreciate you for this redirection. Please keep up your this type of really good support.

Thanks again!

You are welcome, I am glad to help you :)