How to override getAddUrl in class Mage_Checkout_Helper_Cart?Bypass Magento's form key usage to allow simple product to be added to cartExclude a specific categoryForm Key Problems After Changing Domains 1.9.2.1getVisitorData() returns NULL on Category Page only in magento-1.9.2.2How to add a custom page with cross-sell productsShopping cart is empty after cancel the payment in magento-1.9.1.1A problem in order details returnMagento model not fetching dataCheckout redirecting to the cart pageMagento 1.9.3.9 PayFlow API - Multiple Issues

What's the 1 inch size square knob sticking out of wall?

Extrapolation v. Interpolation

Some complicated clues

Sci-fi short story: plants attracting spaceship and using them as a agents of pollination between two planets

My current job follows "worst practices". How can I talk about my experience in an interview without giving off red flags?

What is the purpose of this "red room" in "Stranger Things"?

How can the artificial womb be made affordable for the common people?

Is an easily guessed plot twist a good plot twist?

Monty Hall Problem with a Fallible Monty

Why is chess failing to attract big name sponsors?

Can 々 stand for a duplicated kanji with a different reading?

Why does the salt in the oceans not sink to the bottom?

How can I show that the speed of light in vacuum is the same in all reference frames?

Can't understand how static works exactly

Why is DC so, so, so Democratic?

Are gangsters hired to attack people at a train station classified as a terrorist attack?

Why is the UH-60 tail rotor canted?

How to repair basic cable/wire issue for household appliances

what to say when a company asks you why someone (a friend) who was fired left?

In a script how can I signal who's winning the argument?

Is it possible to eat quietly in Minecraft?

how to add 1 milliseconds on a datetime string?

How can I tell if there was a power cut when I was out?

Are symplectomorphisms of Weil–Petersson symplectic form induced from surface diffeomorphisms?



How to override getAddUrl in class Mage_Checkout_Helper_Cart?


Bypass Magento's form key usage to allow simple product to be added to cartExclude a specific categoryForm Key Problems After Changing Domains 1.9.2.1getVisitorData() returns NULL on Category Page only in magento-1.9.2.2How to add a custom page with cross-sell productsShopping cart is empty after cancel the payment in magento-1.9.1.1A problem in order details returnMagento model not fetching dataCheckout redirecting to the cart pageMagento 1.9.3.9 PayFlow API - Multiple Issues






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a problem with changing getAddUrl() method in magento. In this method:



public function getAddUrl($product, $additional = array())

$routeParams = array(
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
->urlEncode($this->getCurrentUrl()),
'product' => $product->getEntityId(),
Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
);

if (!empty($additional))
$routeParams = array_merge($routeParams, $additional);


if ($product->hasUrlDataObject())
$routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
$routeParams['_store_to_url'] = true;


if ($this->_getRequest()->getRouteName() == 'checkout'
&& $this->_getRequest()->getControllerName() == 'cart')
$routeParams['in_cart'] = 1;


return $this->_getUrl('checkout/cart/add', $routeParams);



we have line:



Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
->urlEncode($this->getCurrentUrl()),


I need to change the current url to another:



Mage::getSingleton('core/session')->getLastUrl()


But i do not know what is the proper way to do this.
Thanks in advance for all tips.










share|improve this question




























    0















    I have a problem with changing getAddUrl() method in magento. In this method:



    public function getAddUrl($product, $additional = array())

    $routeParams = array(
    Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
    ->urlEncode($this->getCurrentUrl()),
    'product' => $product->getEntityId(),
    Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
    );

    if (!empty($additional))
    $routeParams = array_merge($routeParams, $additional);


    if ($product->hasUrlDataObject())
    $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
    $routeParams['_store_to_url'] = true;


    if ($this->_getRequest()->getRouteName() == 'checkout'
    && $this->_getRequest()->getControllerName() == 'cart')
    $routeParams['in_cart'] = 1;


    return $this->_getUrl('checkout/cart/add', $routeParams);



    we have line:



    Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
    ->urlEncode($this->getCurrentUrl()),


    I need to change the current url to another:



    Mage::getSingleton('core/session')->getLastUrl()


    But i do not know what is the proper way to do this.
    Thanks in advance for all tips.










    share|improve this question
























      0












      0








      0








      I have a problem with changing getAddUrl() method in magento. In this method:



      public function getAddUrl($product, $additional = array())

      $routeParams = array(
      Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
      ->urlEncode($this->getCurrentUrl()),
      'product' => $product->getEntityId(),
      Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
      );

      if (!empty($additional))
      $routeParams = array_merge($routeParams, $additional);


      if ($product->hasUrlDataObject())
      $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
      $routeParams['_store_to_url'] = true;


      if ($this->_getRequest()->getRouteName() == 'checkout'
      && $this->_getRequest()->getControllerName() == 'cart')
      $routeParams['in_cart'] = 1;


      return $this->_getUrl('checkout/cart/add', $routeParams);



      we have line:



      Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
      ->urlEncode($this->getCurrentUrl()),


      I need to change the current url to another:



      Mage::getSingleton('core/session')->getLastUrl()


      But i do not know what is the proper way to do this.
      Thanks in advance for all tips.










      share|improve this question














      I have a problem with changing getAddUrl() method in magento. In this method:



      public function getAddUrl($product, $additional = array())

      $routeParams = array(
      Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
      ->urlEncode($this->getCurrentUrl()),
      'product' => $product->getEntityId(),
      Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
      );

      if (!empty($additional))
      $routeParams = array_merge($routeParams, $additional);


      if ($product->hasUrlDataObject())
      $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
      $routeParams['_store_to_url'] = true;


      if ($this->_getRequest()->getRouteName() == 'checkout'
      && $this->_getRequest()->getControllerName() == 'cart')
      $routeParams['in_cart'] = 1;


      return $this->_getUrl('checkout/cart/add', $routeParams);



      we have line:



      Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
      ->urlEncode($this->getCurrentUrl()),


      I need to change the current url to another:



      Mage::getSingleton('core/session')->getLastUrl()


      But i do not know what is the proper way to do this.
      Thanks in advance for all tips.







      magento-1.9






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 15 at 9:46









      SebastianTSebastianT

      526 bronze badges




      526 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          1














          Try following way to overwrite class:




          app/code/local/SR/MagentoCommunity/etc/config.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <SR_MagentoCommunity>
          <version>0.0.0.2</version>
          </SR_MagentoCommunity>
          </modules>
          <global>
          <helpers>
          <checkout>
          <rewrite>
          <cart>SR_MagentoCommunity_Helper_Cart</cart>
          </rewrite>
          </checkout>
          </helpers>
          </global>
          </config>



          app/code/local/SR/MagentoCommunity/Helper/Cart.php




          Modify here as your need



          <?php
          class SR_MagentoCommunity_Helper_Cart extends Mage_Checkout_Helper_Cart

          public function getAddUrl($product, $additional = array())

          $routeParams = array(
          Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
          ->urlEncode($this->getCurrentUrl()),
          'product' => $product->getEntityId(),
          Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
          );

          if (!empty($additional))
          $routeParams = array_merge($routeParams, $additional);


          if ($product->hasUrlDataObject())
          $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
          $routeParams['_store_to_url'] = true;


          if ($this->_getRequest()->getRouteName() == 'checkout'
          && $this->_getRequest()->getControllerName() == 'cart')
          $routeParams['in_cart'] = 1;


          return $this->_getUrl('checkout/cart/add', $routeParams);





          app/etc/modules/SR_MagentoCommunity.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <SR_MagentoCommunity>
          <active>true</active>
          <codePool>local</codePool>
          </SR_MagentoCommunity>
          </modules>
          </config>





          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f282078%2fhow-to-override-getaddurl-in-class-mage-checkout-helper-cart%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Try following way to overwrite class:




            app/code/local/SR/MagentoCommunity/etc/config.xml




            <?xml version="1.0"?>
            <config>
            <modules>
            <SR_MagentoCommunity>
            <version>0.0.0.2</version>
            </SR_MagentoCommunity>
            </modules>
            <global>
            <helpers>
            <checkout>
            <rewrite>
            <cart>SR_MagentoCommunity_Helper_Cart</cart>
            </rewrite>
            </checkout>
            </helpers>
            </global>
            </config>



            app/code/local/SR/MagentoCommunity/Helper/Cart.php




            Modify here as your need



            <?php
            class SR_MagentoCommunity_Helper_Cart extends Mage_Checkout_Helper_Cart

            public function getAddUrl($product, $additional = array())

            $routeParams = array(
            Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
            ->urlEncode($this->getCurrentUrl()),
            'product' => $product->getEntityId(),
            Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
            );

            if (!empty($additional))
            $routeParams = array_merge($routeParams, $additional);


            if ($product->hasUrlDataObject())
            $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
            $routeParams['_store_to_url'] = true;


            if ($this->_getRequest()->getRouteName() == 'checkout'
            && $this->_getRequest()->getControllerName() == 'cart')
            $routeParams['in_cart'] = 1;


            return $this->_getUrl('checkout/cart/add', $routeParams);





            app/etc/modules/SR_MagentoCommunity.xml




            <?xml version="1.0"?>
            <config>
            <modules>
            <SR_MagentoCommunity>
            <active>true</active>
            <codePool>local</codePool>
            </SR_MagentoCommunity>
            </modules>
            </config>





            share|improve this answer



























              1














              Try following way to overwrite class:




              app/code/local/SR/MagentoCommunity/etc/config.xml




              <?xml version="1.0"?>
              <config>
              <modules>
              <SR_MagentoCommunity>
              <version>0.0.0.2</version>
              </SR_MagentoCommunity>
              </modules>
              <global>
              <helpers>
              <checkout>
              <rewrite>
              <cart>SR_MagentoCommunity_Helper_Cart</cart>
              </rewrite>
              </checkout>
              </helpers>
              </global>
              </config>



              app/code/local/SR/MagentoCommunity/Helper/Cart.php




              Modify here as your need



              <?php
              class SR_MagentoCommunity_Helper_Cart extends Mage_Checkout_Helper_Cart

              public function getAddUrl($product, $additional = array())

              $routeParams = array(
              Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
              ->urlEncode($this->getCurrentUrl()),
              'product' => $product->getEntityId(),
              Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
              );

              if (!empty($additional))
              $routeParams = array_merge($routeParams, $additional);


              if ($product->hasUrlDataObject())
              $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
              $routeParams['_store_to_url'] = true;


              if ($this->_getRequest()->getRouteName() == 'checkout'
              && $this->_getRequest()->getControllerName() == 'cart')
              $routeParams['in_cart'] = 1;


              return $this->_getUrl('checkout/cart/add', $routeParams);





              app/etc/modules/SR_MagentoCommunity.xml




              <?xml version="1.0"?>
              <config>
              <modules>
              <SR_MagentoCommunity>
              <active>true</active>
              <codePool>local</codePool>
              </SR_MagentoCommunity>
              </modules>
              </config>





              share|improve this answer

























                1












                1








                1







                Try following way to overwrite class:




                app/code/local/SR/MagentoCommunity/etc/config.xml




                <?xml version="1.0"?>
                <config>
                <modules>
                <SR_MagentoCommunity>
                <version>0.0.0.2</version>
                </SR_MagentoCommunity>
                </modules>
                <global>
                <helpers>
                <checkout>
                <rewrite>
                <cart>SR_MagentoCommunity_Helper_Cart</cart>
                </rewrite>
                </checkout>
                </helpers>
                </global>
                </config>



                app/code/local/SR/MagentoCommunity/Helper/Cart.php




                Modify here as your need



                <?php
                class SR_MagentoCommunity_Helper_Cart extends Mage_Checkout_Helper_Cart

                public function getAddUrl($product, $additional = array())

                $routeParams = array(
                Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
                ->urlEncode($this->getCurrentUrl()),
                'product' => $product->getEntityId(),
                Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
                );

                if (!empty($additional))
                $routeParams = array_merge($routeParams, $additional);


                if ($product->hasUrlDataObject())
                $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
                $routeParams['_store_to_url'] = true;


                if ($this->_getRequest()->getRouteName() == 'checkout'
                && $this->_getRequest()->getControllerName() == 'cart')
                $routeParams['in_cart'] = 1;


                return $this->_getUrl('checkout/cart/add', $routeParams);





                app/etc/modules/SR_MagentoCommunity.xml




                <?xml version="1.0"?>
                <config>
                <modules>
                <SR_MagentoCommunity>
                <active>true</active>
                <codePool>local</codePool>
                </SR_MagentoCommunity>
                </modules>
                </config>





                share|improve this answer













                Try following way to overwrite class:




                app/code/local/SR/MagentoCommunity/etc/config.xml




                <?xml version="1.0"?>
                <config>
                <modules>
                <SR_MagentoCommunity>
                <version>0.0.0.2</version>
                </SR_MagentoCommunity>
                </modules>
                <global>
                <helpers>
                <checkout>
                <rewrite>
                <cart>SR_MagentoCommunity_Helper_Cart</cart>
                </rewrite>
                </checkout>
                </helpers>
                </global>
                </config>



                app/code/local/SR/MagentoCommunity/Helper/Cart.php




                Modify here as your need



                <?php
                class SR_MagentoCommunity_Helper_Cart extends Mage_Checkout_Helper_Cart

                public function getAddUrl($product, $additional = array())

                $routeParams = array(
                Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->_getHelperInstance('core')
                ->urlEncode($this->getCurrentUrl()),
                'product' => $product->getEntityId(),
                Mage_Core_Model_Url::FORM_KEY => $this->_getSingletonModel('core/session')->getFormKey()
                );

                if (!empty($additional))
                $routeParams = array_merge($routeParams, $additional);


                if ($product->hasUrlDataObject())
                $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
                $routeParams['_store_to_url'] = true;


                if ($this->_getRequest()->getRouteName() == 'checkout'
                && $this->_getRequest()->getControllerName() == 'cart')
                $routeParams['in_cart'] = 1;


                return $this->_getUrl('checkout/cart/add', $routeParams);





                app/etc/modules/SR_MagentoCommunity.xml




                <?xml version="1.0"?>
                <config>
                <modules>
                <SR_MagentoCommunity>
                <active>true</active>
                <codePool>local</codePool>
                </SR_MagentoCommunity>
                </modules>
                </config>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 15 at 10:01









                Sohel RanaSohel Rana

                25.5k3 gold badges47 silver badges65 bronze badges




                25.5k3 gold badges47 silver badges65 bronze badges



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f282078%2fhow-to-override-getaddurl-in-class-mage-checkout-helper-cart%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form