Public Member Functions | |
indexAction () | |
allcartAction () |
Definition at line 35 of file SharedController.php.
allcartAction | ( | ) |
Definition at line 64 of file SharedController.php.
00065 { 00066 $code = (string) $this->getRequest()->getParam('code'); 00067 if (empty($code)) { 00068 $this->_forward('noRoute'); 00069 return; 00070 } 00071 00072 $wishlist = Mage::getModel('wishlist/wishlist')->loadByCode($code); 00073 Mage::getSingleton('checkout/session')->setSharedWishlist($code); 00074 00075 if (!$wishlist->getId()) { 00076 $this->_forward('noRoute'); 00077 return; 00078 } else { 00079 $urls = false; 00080 foreach ($wishlist->getProductCollection() as $item) { 00081 try { 00082 $product = Mage::getModel('catalog/product') 00083 ->load($item->getProductId()); 00084 if ($product->isSalable()){ 00085 Mage::getSingleton('checkout/cart')->addProduct($product); 00086 } 00087 } 00088 catch (Exception $e) { 00089 $url = Mage::getSingleton('checkout/session')->getRedirectUrl(true); 00090 if ($url){ 00091 $url = Mage::getModel('core/url')->getUrl('catalog/product/view', array( 00092 'id'=>$item->getProductId(), 00093 'wishlist_next'=>1 00094 )); 00095 00096 $urls[] = $url; 00097 $messages[] = $e->getMessage(); 00098 $wishlistIds[] = $item->getId(); 00099 } 00100 } 00101 00102 Mage::getSingleton('checkout/cart')->save(); 00103 } 00104 if ($urls) { 00105 Mage::getSingleton('checkout/session')->addError(array_shift($messages)); 00106 $this->getResponse()->setRedirect(array_shift($urls)); 00107 00108 Mage::getSingleton('checkout/session')->setWishlistPendingUrls($urls); 00109 Mage::getSingleton('checkout/session')->setWishlistPendingMessages($messages); 00110 Mage::getSingleton('checkout/session')->setWishlistIds($wishlistIds); 00111 } else { 00112 $this->_redirect('checkout/cart'); 00113 } 00114 } 00115 }
indexAction | ( | ) |
Definition at line 38 of file SharedController.php.
00039 { 00040 $code = (string) $this->getRequest()->getParam('code'); 00041 if (empty($code)) { 00042 $this->_forward('noRoute'); 00043 return; 00044 } 00045 $wishlist = Mage::getModel('wishlist/wishlist')->loadByCode($code); 00046 00047 if ($wishlist->getCustomerId() && $wishlist->getCustomerId() == Mage::getSingleton('customer/session')->getCustomerId()) { 00048 $this->_redirectUrl(Mage::helper('wishlist')->getListUrl()); 00049 return; 00050 } 00051 00052 if(!$wishlist->getId()) { 00053 $this->_forward('noRoute'); 00054 return; 00055 } else { 00056 Mage::register('shared_wishlist', $wishlist); 00057 $this->loadLayout(); 00058 $this->_initLayoutMessages('wishlist/session'); 00059 $this->renderLayout(); 00060 } 00061 00062 }