Modifying the redirect after editing a product in the cart Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Removing the “minimum purchase” noticeDisable redirect after product add to basketCreate invoice and shipment in magento via cron based on store view and order ageExclude a specific categoryWrong tax calculation (hiddentax and rowtax) for b2b on Magento CE 1.9.1.0Magento email queue problemsShopping cart is empty after cancel the payment in magento-1.9.1.1Magento 2: Add a product to the cart programmaticallySOLVED Error “Cannot add the item to shopping cart.” after upgrading to Magento 1.9.3.9Magento 2 not passing minimum QTY when adding related products to cart

Should man-made satellites feature an intelligent inverted "cow catcher"?

2 sample t test for sample sizes - 30,000 and 150,000

What is the ongoing value of the Kanban board to the developers as opposed to management

Why is ArcGIS Pro not symbolizing my entire range of values?

How to break 信じようとしていただけかも知れない into separate parts?

A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?

“Since the train was delayed for more than an hour, passengers were given a full refund.” – Why is there no article before “passengers”?

Can I take recommendation from someone I met at a conference?

When does Bran Stark remember Jamie pushing him?

What were wait-states, and why was it only an issue for PCs?

Why do people think Winterfell crypts is the safest place for women, children & old people?

Weaponising the Grasp-at-a-Distance spell

Is it OK if I do not take the receipt in Germany?

Like totally amazing interchangeable sister outfit accessory swapping or whatever

Continue tikz picture on next page

Is "ein Herz wie das meine" an antiquated or colloquial use of the possesive pronoun?

Determine the generator of an ideal of ring of integers

Reflections in a Square

What is the definining line between a helicopter and a drone a person can ride in?

Has a Nobel Peace laureate ever been accused of war crimes?

Is there a verb for listening stealthily?

Does Prince Arnaud cause someone holding the Princess to lose?

What's the connection between Mr. Nancy and fried chicken?

Converting a text document with special format to Pandas DataFrame



Modifying the redirect after editing a product in the cart



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Removing the “minimum purchase” noticeDisable redirect after product add to basketCreate invoice and shipment in magento via cron based on store view and order ageExclude a specific categoryWrong tax calculation (hiddentax and rowtax) for b2b on Magento CE 1.9.1.0Magento email queue problemsShopping cart is empty after cancel the payment in magento-1.9.1.1Magento 2: Add a product to the cart programmaticallySOLVED Error “Cannot add the item to shopping cart.” after upgrading to Magento 1.9.3.9Magento 2 not passing minimum QTY when adding related products to cart



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








3















I have a problem modifying a redirect in magento CE 1.9.2.



Let's say a customer has a configurable product in the cart, and would like to edit that product (ie. changing color or size or something).



After changing the options and clicking the 'update cart' button I want the customer to stay on the same page (ie. the edit product page). However magento always redirect back to the cart page.



I think I've found source of the problem, in CartController.php from the Checkout module:



/**
* Update product configuration for a cart item
*/
public function updateItemOptionsAction()

$cart = $this->_getCart();
$id = (int) $this->getRequest()->getParam('id');
$params = $this->getRequest()->getParams();

if (!isset($params['options']))
$params['options'] = array();

try
if (isset($params['qty']))
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);


$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem)
Mage::throwException($this->__('Quote item is not found.'));


$item = $cart->updateItem($id, new Varien_Object($params));
if (is_string($item))
Mage::throwException($item);

if ($item->getHasError())
Mage::throwException($item->getMessage());


$related = $this->getRequest()->getParam('related_product');
if (!empty($related))
$cart->addProductsByIds(explode(',', $related));


$cart->save();

$this->_getSession()->setCartWasUpdated(true);

Mage::dispatchEvent('checkout_cart_update_item_complete',
array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
if (!$this->_getSession()->getNoCartRedirect(true))
if (!$cart->getQuote()->getHasError())
$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
$this->_getSession()->addSuccess($message);

$this->_goBack();

catch (Mage_Core_Exception $e)
if ($this->_getSession()->getUseNotice(true))
$this->_getSession()->addNotice($e->getMessage());
else
$messages = array_unique(explode("n", $e->getMessage()));
foreach ($messages as $message)
$this->_getSession()->addError($message);



$url = $this->_getSession()->getRedirectUrl(true);
if ($url)
$this->getResponse()->setRedirect($url);
else
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());

catch (Exception $e)
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();

$this->_redirect('*/*');



The call to $this->_goBack() in the end of the try-block seems to set the redirect URL correctly by looking at settings and a 'return_url' parameter (and I've verified that the code gets this far). But, as you can see, the last line always sets a redirect to */* no matter what. Just adding a return statement after the _goBack() call fixes the problem but I rather do this without modifying the core files.



Any ideas how I can solve this problem?










share|improve this question














bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

    – Julien Lachal
    Jul 23 '15 at 14:38

















3















I have a problem modifying a redirect in magento CE 1.9.2.



Let's say a customer has a configurable product in the cart, and would like to edit that product (ie. changing color or size or something).



After changing the options and clicking the 'update cart' button I want the customer to stay on the same page (ie. the edit product page). However magento always redirect back to the cart page.



I think I've found source of the problem, in CartController.php from the Checkout module:



/**
* Update product configuration for a cart item
*/
public function updateItemOptionsAction()

$cart = $this->_getCart();
$id = (int) $this->getRequest()->getParam('id');
$params = $this->getRequest()->getParams();

if (!isset($params['options']))
$params['options'] = array();

try
if (isset($params['qty']))
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);


$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem)
Mage::throwException($this->__('Quote item is not found.'));


$item = $cart->updateItem($id, new Varien_Object($params));
if (is_string($item))
Mage::throwException($item);

if ($item->getHasError())
Mage::throwException($item->getMessage());


$related = $this->getRequest()->getParam('related_product');
if (!empty($related))
$cart->addProductsByIds(explode(',', $related));


$cart->save();

$this->_getSession()->setCartWasUpdated(true);

Mage::dispatchEvent('checkout_cart_update_item_complete',
array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
if (!$this->_getSession()->getNoCartRedirect(true))
if (!$cart->getQuote()->getHasError())
$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
$this->_getSession()->addSuccess($message);

$this->_goBack();

catch (Mage_Core_Exception $e)
if ($this->_getSession()->getUseNotice(true))
$this->_getSession()->addNotice($e->getMessage());
else
$messages = array_unique(explode("n", $e->getMessage()));
foreach ($messages as $message)
$this->_getSession()->addError($message);



$url = $this->_getSession()->getRedirectUrl(true);
if ($url)
$this->getResponse()->setRedirect($url);
else
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());

catch (Exception $e)
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();

$this->_redirect('*/*');



The call to $this->_goBack() in the end of the try-block seems to set the redirect URL correctly by looking at settings and a 'return_url' parameter (and I've verified that the code gets this far). But, as you can see, the last line always sets a redirect to */* no matter what. Just adding a return statement after the _goBack() call fixes the problem but I rather do this without modifying the core files.



Any ideas how I can solve this problem?










share|improve this question














bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

    – Julien Lachal
    Jul 23 '15 at 14:38













3












3








3








I have a problem modifying a redirect in magento CE 1.9.2.



Let's say a customer has a configurable product in the cart, and would like to edit that product (ie. changing color or size or something).



After changing the options and clicking the 'update cart' button I want the customer to stay on the same page (ie. the edit product page). However magento always redirect back to the cart page.



I think I've found source of the problem, in CartController.php from the Checkout module:



/**
* Update product configuration for a cart item
*/
public function updateItemOptionsAction()

$cart = $this->_getCart();
$id = (int) $this->getRequest()->getParam('id');
$params = $this->getRequest()->getParams();

if (!isset($params['options']))
$params['options'] = array();

try
if (isset($params['qty']))
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);


$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem)
Mage::throwException($this->__('Quote item is not found.'));


$item = $cart->updateItem($id, new Varien_Object($params));
if (is_string($item))
Mage::throwException($item);

if ($item->getHasError())
Mage::throwException($item->getMessage());


$related = $this->getRequest()->getParam('related_product');
if (!empty($related))
$cart->addProductsByIds(explode(',', $related));


$cart->save();

$this->_getSession()->setCartWasUpdated(true);

Mage::dispatchEvent('checkout_cart_update_item_complete',
array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
if (!$this->_getSession()->getNoCartRedirect(true))
if (!$cart->getQuote()->getHasError())
$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
$this->_getSession()->addSuccess($message);

$this->_goBack();

catch (Mage_Core_Exception $e)
if ($this->_getSession()->getUseNotice(true))
$this->_getSession()->addNotice($e->getMessage());
else
$messages = array_unique(explode("n", $e->getMessage()));
foreach ($messages as $message)
$this->_getSession()->addError($message);



$url = $this->_getSession()->getRedirectUrl(true);
if ($url)
$this->getResponse()->setRedirect($url);
else
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());

catch (Exception $e)
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();

$this->_redirect('*/*');



The call to $this->_goBack() in the end of the try-block seems to set the redirect URL correctly by looking at settings and a 'return_url' parameter (and I've verified that the code gets this far). But, as you can see, the last line always sets a redirect to */* no matter what. Just adding a return statement after the _goBack() call fixes the problem but I rather do this without modifying the core files.



Any ideas how I can solve this problem?










share|improve this question














I have a problem modifying a redirect in magento CE 1.9.2.



Let's say a customer has a configurable product in the cart, and would like to edit that product (ie. changing color or size or something).



After changing the options and clicking the 'update cart' button I want the customer to stay on the same page (ie. the edit product page). However magento always redirect back to the cart page.



I think I've found source of the problem, in CartController.php from the Checkout module:



/**
* Update product configuration for a cart item
*/
public function updateItemOptionsAction()

$cart = $this->_getCart();
$id = (int) $this->getRequest()->getParam('id');
$params = $this->getRequest()->getParams();

if (!isset($params['options']))
$params['options'] = array();

try
if (isset($params['qty']))
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);


$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem)
Mage::throwException($this->__('Quote item is not found.'));


$item = $cart->updateItem($id, new Varien_Object($params));
if (is_string($item))
Mage::throwException($item);

if ($item->getHasError())
Mage::throwException($item->getMessage());


$related = $this->getRequest()->getParam('related_product');
if (!empty($related))
$cart->addProductsByIds(explode(',', $related));


$cart->save();

$this->_getSession()->setCartWasUpdated(true);

Mage::dispatchEvent('checkout_cart_update_item_complete',
array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
if (!$this->_getSession()->getNoCartRedirect(true))
if (!$cart->getQuote()->getHasError())
$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
$this->_getSession()->addSuccess($message);

$this->_goBack();

catch (Mage_Core_Exception $e)
if ($this->_getSession()->getUseNotice(true))
$this->_getSession()->addNotice($e->getMessage());
else
$messages = array_unique(explode("n", $e->getMessage()));
foreach ($messages as $message)
$this->_getSession()->addError($message);



$url = $this->_getSession()->getRedirectUrl(true);
if ($url)
$this->getResponse()->setRedirect($url);
else
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());

catch (Exception $e)
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();

$this->_redirect('*/*');



The call to $this->_goBack() in the end of the try-block seems to set the redirect URL correctly by looking at settings and a 'return_url' parameter (and I've verified that the code gets this far). But, as you can see, the last line always sets a redirect to */* no matter what. Just adding a return statement after the _goBack() call fixes the problem but I rather do this without modifying the core files.



Any ideas how I can solve this problem?







magento-1.9 cart redirect magento-ce






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 23 '15 at 14:15









Simon StrandmanSimon Strandman

162




162





bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

    – Julien Lachal
    Jul 23 '15 at 14:38

















  • You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

    – Julien Lachal
    Jul 23 '15 at 14:38
















You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

– Julien Lachal
Jul 23 '15 at 14:38





You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

– Julien Lachal
Jul 23 '15 at 14:38










1 Answer
1






active

oldest

votes


















0














If you want the customer to say on the update page you could



  1. Use Ajax to post the changes to the server.


  2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


  3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


  4. Rewrite the controller using a custom module






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%2f75478%2fmodifying-the-redirect-after-editing-a-product-in-the-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









    0














    If you want the customer to say on the update page you could



    1. Use Ajax to post the changes to the server.


    2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


    3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


    4. Rewrite the controller using a custom module






    share|improve this answer



























      0














      If you want the customer to say on the update page you could



      1. Use Ajax to post the changes to the server.


      2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


      3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


      4. Rewrite the controller using a custom module






      share|improve this answer

























        0












        0








        0







        If you want the customer to say on the update page you could



        1. Use Ajax to post the changes to the server.


        2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


        3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


        4. Rewrite the controller using a custom module






        share|improve this answer













        If you want the customer to say on the update page you could



        1. Use Ajax to post the changes to the server.


        2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


        3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


        4. Rewrite the controller using a custom module







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 23 '15 at 14:41









        Renon StewartRenon Stewart

        12.2k12044




        12.2k12044



























            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%2f75478%2fmodifying-the-redirect-after-editing-a-product-in-the-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

            Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

            Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

            Aasi (pallopeli) Navigointivalikko