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

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

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?