1

I am using the extension "Add Free Product to cart". I noticed that customers can't use the website anymore, if they have more than exact 31 articles in their cart. If they put more than 31 articles in their cart, then the website is starting to download instead of getting rendered.

There are 3 Add free product to cart rules set at the moment which are all bound to category id 18. If I disable one rule, then it works again and the customer can visit the site normally without it getting downloaded. The bug is even then triggered if the articles are not matching the category specified as condition in the rule, so the problem must be related to the cookies and not to the rules itself which are working fine.

A cookie is set for each article which describes if the conditions from a rule are true for that article or not, if there are three rules then there will be three cookies, for each article.

Normaly the value of the response Header content-type should be set to text/html; charset=UTF-8, but if the bug is triggered and the website is downloaded instead of getting rendered in the browser, then the content-type is set to application/x-httpd-ea-php70 (even though magento 1.8 uses Php 5 btw...`?)

I think the error happens because magento or the extension can't handle more than 100 set-cookie requests?

enter image description here

3
  • I found the solution. It was a bug in the helper class of the extension.
    – Black
    Commented Sep 11, 2018 at 13:44
  • I also encountered the same issue. Can you please share the bug that you've found in the helper class of the extension? Thanks. Commented Jan 14, 2019 at 12:19
  • @YubiA., Ok, I posted my bugfix.
    – Black
    Commented Jan 14, 2019 at 15:31

3 Answers 3

2

Blockquote I think the error happens because magento can't handle so many cookies?

Seems like cookies have limit of their size by browsers (https://stackoverflow.com/questions/640938/what-is-the-maximum-size-of-a-web-browsers-cookies-key) so may be your cookie is cut and that leads to this behavior.

UPD More useful link: http://browsercookielimits.squawky.net

4
  • No, I don't think that this is the problem. The cookie size is only149 chars. But still a good hint! Thanks!
    – Black
    Commented Jun 20, 2018 at 12:00
  • In fact i see loop of set-cookie headers (of same 2 cookies) on your added screenshot and final cookie may be too large, reload that page and check Cookie header in your request (not response).
    – Fumafu
    Commented Jun 20, 2018 at 13:04
  • I reloaded and this is in the Request Headers Section at cookie: aw-afptc-rule-decline-68=0; aw-afptc-rule-decline-69=0; aw-afptc-rule-decline-70=0;
    – Black
    Commented Jun 20, 2018 at 13:10
  • Well, no more ideas then, sorry, except the count of these set-cookie headers but may be i just don't understand output of your software.
    – Fumafu
    Commented Jun 20, 2018 at 13:14
1

I was able to fix the bug.

File: app\code\local\AW\Afptc\Helper\Data.php

Before:

public function removeDeclineCookies()
{
    $cookie = Mage::getSingleton('core/cookie');
    $store = Mage::app()->getStore();
    $rulesCollection = Mage::getResourceModel('awafptc/rule')->getActiveRulesCollection($store);
    foreach ($rulesCollection as $rule) {            
        $cookie->set($this->getDeclineRuleCookieName($rule->getId()), '0', time() + $this->getCookieLifetime(),'/');
    }
    return $this;
}

After:

public function removeDeclineCookies()
{
    $cookie = Mage::getSingleton('core/cookie');
    $store = Mage::app()->getStore();
    $rulesCollection = Mage::getResourceModel('awafptc/rule')->getActiveRulesCollection($store);
    foreach ($rulesCollection as $rule) {
        $cookieName = $this->getDeclineRuleCookieName($rule->getId());

        if ($cookie->get($cookieName) != '0') {
            $cookie->set($cookieName, '0', time() + $this->getCookieLifetime(),'/');
        }
    }
    return $this;
}
0

Are you sure you are testing the latest version? I am using 1.1.15, tried your scenario but nothing wrong happened. Checked the changelog and it seems something similar was fixed a long time ago: Released 17.08.2017 502 Bad Gateway error when 3 or greater free products are added to cart

1
  • No, we are using an older version. I already fixed the bug in it though. I don't know the credentials for the marketplace account, so I can't update the extension.
    – Black
    Commented Jun 23, 2018 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.