Remove wishlist items when added to cart Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Magento 2 - Keep Wishlist itemsRemove from wishlist URL?Automatically remove cart itemsSame product added to cart - different line itemsMultiple Items in wishlistCode to enable downloadable product?how to remove login check when item added to wishlist?How to remove wishlistWishlist items replaced on addRemove item from wishlist when boughtRedirection issues of cart and wishlist when remove item in magento 1.9?

Is Bran literally the world's memory?

When speaking, how do you change your mind mid-sentence?

Why does the Cisco show run command not show the full version, while the show version command does?

Why aren't road bicycle wheels tiny?

Is there an efficient way for synchronising audio events real-time with LEDs using an MCU?

Like totally amazing interchangeable sister outfit accessory swapping or whatever

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

Determinant of a matrix with 2 equal rows

Are there existing rules/lore for MTG planeswalkers?

Where/What are Arya's scars from?

Philosophers who were composers?

Raising a bilingual kid. When should we introduce the majority language?

France's Public Holidays' Puzzle

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

What is the numbering system used for the DSN dishes?

RIP Packet Format

What was Apollo 13's "Little Jolt" after MECO?

Is it accepted to use working hours to read general interest books?

What's parked in Mil Moscow helicopter plant?

Why is arima in R one time step off?

Will I be more secure with my own router behind my ISP's router?

Why did Israel vote against lifting the American embargo on Cuba?

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

Why isPrototypeOf() returns false?



Remove wishlist items when added to cart



Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento 2 - Keep Wishlist itemsRemove from wishlist URL?Automatically remove cart itemsSame product added to cart - different line itemsMultiple Items in wishlistCode to enable downloadable product?how to remove login check when item added to wishlist?How to remove wishlistWishlist items replaced on addRemove item from wishlist when boughtRedirection issues of cart and wishlist when remove item in magento 1.9?



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








0















I want to remove the wishlist products that are added to the cart. I've followed this link: Keeping wishlist items for keeping the wish list items after being added to the cart.i have set my $delete to true as shown in the code below but the product isn't removed from the wishlist.



Here is my indexcontroller.php path and code




app/code/core/Mage/Wishlist/controllers/IndexController.php




/**
* Add wishlist item to shopping cart and remove from wishlist
*
* If Product has required options - item removed from wishlist and redirect
* to product view page with message about needed defined required options
*/

public function cartAction()

if (!$this->_validateFormKey())
return $this->_redirect('*/*');

$itemId = (int) $this->getRequest()->getParam('item');

/* @var $item Mage_Wishlist_Model_Item */
$item = Mage::getModel('wishlist/item')->load($itemId);
if (!$item->getId())
return $this->_redirect('*/*');

$wishlist = $this->_getWishlist($item->getWishlistId());
if (!$wishlist)
return $this->_redirect('*/*');


// Set qty
$qty = $this->getRequest()->getParam('qty');
if (is_array($qty))
if (isset($qty[$itemId]))
$qty = $qty[$itemId];
else
$qty = 1;


$qty = $this->_processLocalizedQty($qty);
if ($qty)
$item->setQty($qty);


/* @var $session Mage_Wishlist_Model_Session */
$session = Mage::getSingleton('wishlist/session');
$cart = Mage::getSingleton('checkout/cart');

$redirectUrl = Mage::getUrl('*/*');

try
$options = Mage::getModel('wishlist/item_option')->getCollection()
->addItemFilter(array($itemId));
$item->setOptions($options->getOptionsByItem($itemId));

$buyRequest = Mage::helper('catalog/product')->addParamsToBuyRequest(
$this->getRequest()->getParams(),
array('current_config' => $item->getBuyRequest())
);

$item->mergeBuyRequest($buyRequest);

if ($item->addToCart($cart, true))
$cart->save()->getQuote()->collectTotals();



$wishlist->save();
Mage::helper('wishlist')->calculate();

if (Mage::helper('checkout/cart')->getShouldRedirectToCart())
$redirectUrl = Mage::helper('checkout/cart')->getCartUrl();

Mage::helper('wishlist')->calculate();

$product = Mage::getModel('catalog/product')
->setStoreId(Mage::app()->getStore()->getId())
->load($item->getProductId());
$productName = Mage::helper('core')->escapeHtml($product->getName());
$message = $this->__('%s was added to your shopping cart.', $productName);
Mage::getSingleton('catalog/session')->addSuccess($message);
catch (Mage_Core_Exception $e)
if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_NOT_SALABLE)
$session->addError($this->__('This product(s) is currently out of stock'));
else if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS)
Mage::getSingleton('catalog/session')->addNotice($e->getMessage());
$redirectUrl = Mage::getUrl('*/*/configure/', array('id' => $item->getId()));
else
Mage::getSingleton('catalog/session')->addNotice($e->getMessage());
$redirectUrl = Mage::getUrl('*/*/configure/', array('id' => $item->getId()));

catch (Exception $e)
Mage::logException($e);
$session->addException($e, $this->__('Cannot add item to shopping cart'));


Mage::helper('wishlist')->calculate();

return $this->_redirectUrl($redirectUrl);



Here is my Item.php path and code




app/code/core/Mage/Wishlist/Model/Item.php




 /**
* Add or Move item product to shopping cart
*
* Return true if product was successful added or exception with code
* Return false for disabled or unvisible products
*
* @throws Mage_Core_Exception
* @param Mage_Checkout_Model_Cart $cart
* @param bool $delete delete the item after successful add to cart
* @return bool
*/
public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=true)

$product = $this->getProduct();
$storeId = $this->getStoreId();

if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
return false;


if (!$product->isVisibleInSiteVisibility())
if ($product->getStoreId() == $storeId)
return false;



if (!$product->isSalable())
throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


$buyRequest = $this->getBuyRequest();

$cart->addProduct($product, $buyRequest);
if (!$product->isVisibleInSiteVisibility())
$cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


if ($delete)
$this->delete();


return true;










share|improve this question






























    0















    I want to remove the wishlist products that are added to the cart. I've followed this link: Keeping wishlist items for keeping the wish list items after being added to the cart.i have set my $delete to true as shown in the code below but the product isn't removed from the wishlist.



    Here is my indexcontroller.php path and code




    app/code/core/Mage/Wishlist/controllers/IndexController.php




    /**
    * Add wishlist item to shopping cart and remove from wishlist
    *
    * If Product has required options - item removed from wishlist and redirect
    * to product view page with message about needed defined required options
    */

    public function cartAction()

    if (!$this->_validateFormKey())
    return $this->_redirect('*/*');

    $itemId = (int) $this->getRequest()->getParam('item');

    /* @var $item Mage_Wishlist_Model_Item */
    $item = Mage::getModel('wishlist/item')->load($itemId);
    if (!$item->getId())
    return $this->_redirect('*/*');

    $wishlist = $this->_getWishlist($item->getWishlistId());
    if (!$wishlist)
    return $this->_redirect('*/*');


    // Set qty
    $qty = $this->getRequest()->getParam('qty');
    if (is_array($qty))
    if (isset($qty[$itemId]))
    $qty = $qty[$itemId];
    else
    $qty = 1;


    $qty = $this->_processLocalizedQty($qty);
    if ($qty)
    $item->setQty($qty);


    /* @var $session Mage_Wishlist_Model_Session */
    $session = Mage::getSingleton('wishlist/session');
    $cart = Mage::getSingleton('checkout/cart');

    $redirectUrl = Mage::getUrl('*/*');

    try
    $options = Mage::getModel('wishlist/item_option')->getCollection()
    ->addItemFilter(array($itemId));
    $item->setOptions($options->getOptionsByItem($itemId));

    $buyRequest = Mage::helper('catalog/product')->addParamsToBuyRequest(
    $this->getRequest()->getParams(),
    array('current_config' => $item->getBuyRequest())
    );

    $item->mergeBuyRequest($buyRequest);

    if ($item->addToCart($cart, true))
    $cart->save()->getQuote()->collectTotals();



    $wishlist->save();
    Mage::helper('wishlist')->calculate();

    if (Mage::helper('checkout/cart')->getShouldRedirectToCart())
    $redirectUrl = Mage::helper('checkout/cart')->getCartUrl();

    Mage::helper('wishlist')->calculate();

    $product = Mage::getModel('catalog/product')
    ->setStoreId(Mage::app()->getStore()->getId())
    ->load($item->getProductId());
    $productName = Mage::helper('core')->escapeHtml($product->getName());
    $message = $this->__('%s was added to your shopping cart.', $productName);
    Mage::getSingleton('catalog/session')->addSuccess($message);
    catch (Mage_Core_Exception $e)
    if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_NOT_SALABLE)
    $session->addError($this->__('This product(s) is currently out of stock'));
    else if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS)
    Mage::getSingleton('catalog/session')->addNotice($e->getMessage());
    $redirectUrl = Mage::getUrl('*/*/configure/', array('id' => $item->getId()));
    else
    Mage::getSingleton('catalog/session')->addNotice($e->getMessage());
    $redirectUrl = Mage::getUrl('*/*/configure/', array('id' => $item->getId()));

    catch (Exception $e)
    Mage::logException($e);
    $session->addException($e, $this->__('Cannot add item to shopping cart'));


    Mage::helper('wishlist')->calculate();

    return $this->_redirectUrl($redirectUrl);



    Here is my Item.php path and code




    app/code/core/Mage/Wishlist/Model/Item.php




     /**
    * Add or Move item product to shopping cart
    *
    * Return true if product was successful added or exception with code
    * Return false for disabled or unvisible products
    *
    * @throws Mage_Core_Exception
    * @param Mage_Checkout_Model_Cart $cart
    * @param bool $delete delete the item after successful add to cart
    * @return bool
    */
    public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=true)

    $product = $this->getProduct();
    $storeId = $this->getStoreId();

    if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
    return false;


    if (!$product->isVisibleInSiteVisibility())
    if ($product->getStoreId() == $storeId)
    return false;



    if (!$product->isSalable())
    throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


    $buyRequest = $this->getBuyRequest();

    $cart->addProduct($product, $buyRequest);
    if (!$product->isVisibleInSiteVisibility())
    $cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


    if ($delete)
    $this->delete();


    return true;










    share|improve this question


























      0












      0








      0








      I want to remove the wishlist products that are added to the cart. I've followed this link: Keeping wishlist items for keeping the wish list items after being added to the cart.i have set my $delete to true as shown in the code below but the product isn't removed from the wishlist.



      Here is my indexcontroller.php path and code




      app/code/core/Mage/Wishlist/controllers/IndexController.php




      /**
      * Add wishlist item to shopping cart and remove from wishlist
      *
      * If Product has required options - item removed from wishlist and redirect
      * to product view page with message about needed defined required options
      */

      public function cartAction()

      if (!$this->_validateFormKey())
      return $this->_redirect('*/*');

      $itemId = (int) $this->getRequest()->getParam('item');

      /* @var $item Mage_Wishlist_Model_Item */
      $item = Mage::getModel('wishlist/item')->load($itemId);
      if (!$item->getId())
      return $this->_redirect('*/*');

      $wishlist = $this->_getWishlist($item->getWishlistId());
      if (!$wishlist)
      return $this->_redirect('*/*');


      // Set qty
      $qty = $this->getRequest()->getParam('qty');
      if (is_array($qty))
      if (isset($qty[$itemId]))
      $qty = $qty[$itemId];
      else
      $qty = 1;


      $qty = $this->_processLocalizedQty($qty);
      if ($qty)
      $item->setQty($qty);


      /* @var $session Mage_Wishlist_Model_Session */
      $session = Mage::getSingleton('wishlist/session');
      $cart = Mage::getSingleton('checkout/cart');

      $redirectUrl = Mage::getUrl('*/*');

      try
      $options = Mage::getModel('wishlist/item_option')->getCollection()
      ->addItemFilter(array($itemId));
      $item->setOptions($options->getOptionsByItem($itemId));

      $buyRequest = Mage::helper('catalog/product')->addParamsToBuyRequest(
      $this->getRequest()->getParams(),
      array('current_config' => $item->getBuyRequest())
      );

      $item->mergeBuyRequest($buyRequest);

      if ($item->addToCart($cart, true))
      $cart->save()->getQuote()->collectTotals();



      $wishlist->save();
      Mage::helper('wishlist')->calculate();

      if (Mage::helper('checkout/cart')->getShouldRedirectToCart())
      $redirectUrl = Mage::helper('checkout/cart')->getCartUrl();

      Mage::helper('wishlist')->calculate();

      $product = Mage::getModel('catalog/product')
      ->setStoreId(Mage::app()->getStore()->getId())
      ->load($item->getProductId());
      $productName = Mage::helper('core')->escapeHtml($product->getName());
      $message = $this->__('%s was added to your shopping cart.', $productName);
      Mage::getSingleton('catalog/session')->addSuccess($message);
      catch (Mage_Core_Exception $e)
      if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_NOT_SALABLE)
      $session->addError($this->__('This product(s) is currently out of stock'));
      else if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS)
      Mage::getSingleton('catalog/session')->addNotice($e->getMessage());
      $redirectUrl = Mage::getUrl('*/*/configure/', array('id' => $item->getId()));
      else
      Mage::getSingleton('catalog/session')->addNotice($e->getMessage());
      $redirectUrl = Mage::getUrl('*/*/configure/', array('id' => $item->getId()));

      catch (Exception $e)
      Mage::logException($e);
      $session->addException($e, $this->__('Cannot add item to shopping cart'));


      Mage::helper('wishlist')->calculate();

      return $this->_redirectUrl($redirectUrl);



      Here is my Item.php path and code




      app/code/core/Mage/Wishlist/Model/Item.php




       /**
      * Add or Move item product to shopping cart
      *
      * Return true if product was successful added or exception with code
      * Return false for disabled or unvisible products
      *
      * @throws Mage_Core_Exception
      * @param Mage_Checkout_Model_Cart $cart
      * @param bool $delete delete the item after successful add to cart
      * @return bool
      */
      public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=true)

      $product = $this->getProduct();
      $storeId = $this->getStoreId();

      if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
      return false;


      if (!$product->isVisibleInSiteVisibility())
      if ($product->getStoreId() == $storeId)
      return false;



      if (!$product->isSalable())
      throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


      $buyRequest = $this->getBuyRequest();

      $cart->addProduct($product, $buyRequest);
      if (!$product->isVisibleInSiteVisibility())
      $cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


      if ($delete)
      $this->delete();


      return true;










      share|improve this question
















      I want to remove the wishlist products that are added to the cart. I've followed this link: Keeping wishlist items for keeping the wish list items after being added to the cart.i have set my $delete to true as shown in the code below but the product isn't removed from the wishlist.



      Here is my indexcontroller.php path and code




      app/code/core/Mage/Wishlist/controllers/IndexController.php




      /**
      * Add wishlist item to shopping cart and remove from wishlist
      *
      * If Product has required options - item removed from wishlist and redirect
      * to product view page with message about needed defined required options
      */

      public function cartAction()

      if (!$this->_validateFormKey())
      return $this->_redirect('*/*');

      $itemId = (int) $this->getRequest()->getParam('item');

      /* @var $item Mage_Wishlist_Model_Item */
      $item = Mage::getModel('wishlist/item')->load($itemId);
      if (!$item->getId())
      return $this->_redirect('*/*');

      $wishlist = $this->_getWishlist($item->getWishlistId());
      if (!$wishlist)
      return $this->_redirect('*/*');


      // Set qty
      $qty = $this->getRequest()->getParam('qty');
      if (is_array($qty))
      if (isset($qty[$itemId]))
      $qty = $qty[$itemId];
      else
      $qty = 1;


      $qty = $this->_processLocalizedQty($qty);
      if ($qty)
      $item->setQty($qty);


      /* @var $session Mage_Wishlist_Model_Session */
      $session = Mage::getSingleton('wishlist/session');
      $cart = Mage::getSingleton('checkout/cart');

      $redirectUrl = Mage::getUrl('*/*');

      try
      $options = Mage::getModel('wishlist/item_option')->getCollection()
      ->addItemFilter(array($itemId));
      $item->setOptions($options->getOptionsByItem($itemId));

      $buyRequest = Mage::helper('catalog/product')->addParamsToBuyRequest(
      $this->getRequest()->getParams(),
      array('current_config' => $item->getBuyRequest())
      );

      $item->mergeBuyRequest($buyRequest);

      if ($item->addToCart($cart, true))
      $cart->save()->getQuote()->collectTotals();



      $wishlist->save();
      Mage::helper('wishlist')->calculate();

      if (Mage::helper('checkout/cart')->getShouldRedirectToCart())
      $redirectUrl = Mage::helper('checkout/cart')->getCartUrl();

      Mage::helper('wishlist')->calculate();

      $product = Mage::getModel('catalog/product')
      ->setStoreId(Mage::app()->getStore()->getId())
      ->load($item->getProductId());
      $productName = Mage::helper('core')->escapeHtml($product->getName());
      $message = $this->__('%s was added to your shopping cart.', $productName);
      Mage::getSingleton('catalog/session')->addSuccess($message);
      catch (Mage_Core_Exception $e)
      if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_NOT_SALABLE)
      $session->addError($this->__('This product(s) is currently out of stock'));
      else if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS)
      Mage::getSingleton('catalog/session')->addNotice($e->getMessage());
      $redirectUrl = Mage::getUrl('*/*/configure/', array('id' => $item->getId()));
      else
      Mage::getSingleton('catalog/session')->addNotice($e->getMessage());
      $redirectUrl = Mage::getUrl('*/*/configure/', array('id' => $item->getId()));

      catch (Exception $e)
      Mage::logException($e);
      $session->addException($e, $this->__('Cannot add item to shopping cart'));


      Mage::helper('wishlist')->calculate();

      return $this->_redirectUrl($redirectUrl);



      Here is my Item.php path and code




      app/code/core/Mage/Wishlist/Model/Item.php




       /**
      * Add or Move item product to shopping cart
      *
      * Return true if product was successful added or exception with code
      * Return false for disabled or unvisible products
      *
      * @throws Mage_Core_Exception
      * @param Mage_Checkout_Model_Cart $cart
      * @param bool $delete delete the item after successful add to cart
      * @return bool
      */
      public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=true)

      $product = $this->getProduct();
      $storeId = $this->getStoreId();

      if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
      return false;


      if (!$product->isVisibleInSiteVisibility())
      if ($product->getStoreId() == $storeId)
      return false;



      if (!$product->isSalable())
      throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


      $buyRequest = $this->getBuyRequest();

      $cart->addProduct($product, $buyRequest);
      if (!$product->isVisibleInSiteVisibility())
      $cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


      if ($delete)
      $this->delete();


      return true;







      product cart wishlist






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 19 at 10:43









      Muhammad Anas

      8031322




      8031322










      asked Dec 2 '18 at 19:30









      Ahmed waelAhmed wael

      1




      1




















          1 Answer
          1






          active

          oldest

          votes


















          0














          The addToCart() method is declared in app/code/core/Mage/Wishlist/Model/Item.php and the second parameter is what triggers the wishlist deletion. If you set it to false it won't delete the item from the wishlist:




          app/code/core/Mage/Wishlist/Model/Item.php




           /**
          * Add or Move item product to shopping cart
          *
          * Return true if product was successful added or exception with code
          * Return false for disabled or unvisible products
          *
          * @throws Mage_Core_Exception
          * @param Mage_Checkout_Model_Cart $cart
          * @param bool $delete delete the item after successful add to cart
          * @return bool
          */
          public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=fasle)

          $product = $this->getProduct();
          $storeId = $this->getStoreId();

          if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
          return false;


          if (!$product->isVisibleInSiteVisibility())
          if ($product->getStoreId() == $storeId)
          return false;



          if (!$product->isSalable())
          throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


          $buyRequest = $this->getBuyRequest();

          $cart->addProduct($product, $buyRequest);
          if (!$product->isVisibleInSiteVisibility())
          $cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


          if ($delete)
          $this->delete();


          return true;






          share|improve this answer























          • Thank you for your concern and answer. Yes after searching magento SE i've realised that the boolean $delete when set to false it doesn't delete the item from the wishlist and when its set to true as shown in my code it must delete the item from the wishlist but its not removed! Any idea where can i be going wrong?

            – Ahmed wael
            Dec 2 '18 at 22:13












          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%2f252124%2fremove-wishlist-items-when-added-to-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














          The addToCart() method is declared in app/code/core/Mage/Wishlist/Model/Item.php and the second parameter is what triggers the wishlist deletion. If you set it to false it won't delete the item from the wishlist:




          app/code/core/Mage/Wishlist/Model/Item.php




           /**
          * Add or Move item product to shopping cart
          *
          * Return true if product was successful added or exception with code
          * Return false for disabled or unvisible products
          *
          * @throws Mage_Core_Exception
          * @param Mage_Checkout_Model_Cart $cart
          * @param bool $delete delete the item after successful add to cart
          * @return bool
          */
          public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=fasle)

          $product = $this->getProduct();
          $storeId = $this->getStoreId();

          if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
          return false;


          if (!$product->isVisibleInSiteVisibility())
          if ($product->getStoreId() == $storeId)
          return false;



          if (!$product->isSalable())
          throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


          $buyRequest = $this->getBuyRequest();

          $cart->addProduct($product, $buyRequest);
          if (!$product->isVisibleInSiteVisibility())
          $cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


          if ($delete)
          $this->delete();


          return true;






          share|improve this answer























          • Thank you for your concern and answer. Yes after searching magento SE i've realised that the boolean $delete when set to false it doesn't delete the item from the wishlist and when its set to true as shown in my code it must delete the item from the wishlist but its not removed! Any idea where can i be going wrong?

            – Ahmed wael
            Dec 2 '18 at 22:13
















          0














          The addToCart() method is declared in app/code/core/Mage/Wishlist/Model/Item.php and the second parameter is what triggers the wishlist deletion. If you set it to false it won't delete the item from the wishlist:




          app/code/core/Mage/Wishlist/Model/Item.php




           /**
          * Add or Move item product to shopping cart
          *
          * Return true if product was successful added or exception with code
          * Return false for disabled or unvisible products
          *
          * @throws Mage_Core_Exception
          * @param Mage_Checkout_Model_Cart $cart
          * @param bool $delete delete the item after successful add to cart
          * @return bool
          */
          public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=fasle)

          $product = $this->getProduct();
          $storeId = $this->getStoreId();

          if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
          return false;


          if (!$product->isVisibleInSiteVisibility())
          if ($product->getStoreId() == $storeId)
          return false;



          if (!$product->isSalable())
          throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


          $buyRequest = $this->getBuyRequest();

          $cart->addProduct($product, $buyRequest);
          if (!$product->isVisibleInSiteVisibility())
          $cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


          if ($delete)
          $this->delete();


          return true;






          share|improve this answer























          • Thank you for your concern and answer. Yes after searching magento SE i've realised that the boolean $delete when set to false it doesn't delete the item from the wishlist and when its set to true as shown in my code it must delete the item from the wishlist but its not removed! Any idea where can i be going wrong?

            – Ahmed wael
            Dec 2 '18 at 22:13














          0












          0








          0







          The addToCart() method is declared in app/code/core/Mage/Wishlist/Model/Item.php and the second parameter is what triggers the wishlist deletion. If you set it to false it won't delete the item from the wishlist:




          app/code/core/Mage/Wishlist/Model/Item.php




           /**
          * Add or Move item product to shopping cart
          *
          * Return true if product was successful added or exception with code
          * Return false for disabled or unvisible products
          *
          * @throws Mage_Core_Exception
          * @param Mage_Checkout_Model_Cart $cart
          * @param bool $delete delete the item after successful add to cart
          * @return bool
          */
          public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=fasle)

          $product = $this->getProduct();
          $storeId = $this->getStoreId();

          if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
          return false;


          if (!$product->isVisibleInSiteVisibility())
          if ($product->getStoreId() == $storeId)
          return false;



          if (!$product->isSalable())
          throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


          $buyRequest = $this->getBuyRequest();

          $cart->addProduct($product, $buyRequest);
          if (!$product->isVisibleInSiteVisibility())
          $cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


          if ($delete)
          $this->delete();


          return true;






          share|improve this answer













          The addToCart() method is declared in app/code/core/Mage/Wishlist/Model/Item.php and the second parameter is what triggers the wishlist deletion. If you set it to false it won't delete the item from the wishlist:




          app/code/core/Mage/Wishlist/Model/Item.php




           /**
          * Add or Move item product to shopping cart
          *
          * Return true if product was successful added or exception with code
          * Return false for disabled or unvisible products
          *
          * @throws Mage_Core_Exception
          * @param Mage_Checkout_Model_Cart $cart
          * @param bool $delete delete the item after successful add to cart
          * @return bool
          */
          public function addToCart(Mage_Checkout_Model_Cart $cart, $delete=fasle)

          $product = $this->getProduct();
          $storeId = $this->getStoreId();

          if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
          return false;


          if (!$product->isVisibleInSiteVisibility())
          if ($product->getStoreId() == $storeId)
          return false;



          if (!$product->isSalable())
          throw new Mage_Core_Exception(null, self::EXCEPTION_CODE_NOT_SALABLE);


          $buyRequest = $this->getBuyRequest();

          $cart->addProduct($product, $buyRequest);
          if (!$product->isVisibleInSiteVisibility())
          $cart->getQuote()->getItemByProduct($product)->setStoreId($storeId);


          if ($delete)
          $this->delete();


          return true;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 2 '18 at 20:04









          Supravat MSupravat M

          1,15611626




          1,15611626












          • Thank you for your concern and answer. Yes after searching magento SE i've realised that the boolean $delete when set to false it doesn't delete the item from the wishlist and when its set to true as shown in my code it must delete the item from the wishlist but its not removed! Any idea where can i be going wrong?

            – Ahmed wael
            Dec 2 '18 at 22:13


















          • Thank you for your concern and answer. Yes after searching magento SE i've realised that the boolean $delete when set to false it doesn't delete the item from the wishlist and when its set to true as shown in my code it must delete the item from the wishlist but its not removed! Any idea where can i be going wrong?

            – Ahmed wael
            Dec 2 '18 at 22:13

















          Thank you for your concern and answer. Yes after searching magento SE i've realised that the boolean $delete when set to false it doesn't delete the item from the wishlist and when its set to true as shown in my code it must delete the item from the wishlist but its not removed! Any idea where can i be going wrong?

          – Ahmed wael
          Dec 2 '18 at 22:13






          Thank you for your concern and answer. Yes after searching magento SE i've realised that the boolean $delete when set to false it doesn't delete the item from the wishlist and when its set to true as shown in my code it must delete the item from the wishlist but its not removed! Any idea where can i be going wrong?

          – Ahmed wael
          Dec 2 '18 at 22:13


















          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%2f252124%2fremove-wishlist-items-when-added-to-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

          Sum ergo cogito? 1 nng

          三茅街道4182Guuntc Dn precexpngmageondP