当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Object::setBuyRequest方法代码示例

本文整理汇总了PHP中Varien_Object::setBuyRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::setBuyRequest方法的具体用法?PHP Varien_Object::setBuyRequest怎么用?PHP Varien_Object::setBuyRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Object的用法示例。


在下文中一共展示了Varien_Object::setBuyRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPrepareCartObserverQty

 /**
  * 
  * @loadFixture testPrepareCart
  * @dataProvider provider__testPrepareCartObserverQty
  * The main goul of this test is to check if the error will be araised if items are added one by one
  *
  */
 public function testPrepareCartObserverQty($dealId, $qty, $productId, $expectedPrice, $infoBuyRequest, $count, $uid)
 {
     $deal = Mage::getModel('collpur/deal')->load($dealId);
     /* set deal id in request */
     Mage::app()->getRequest()->setParam('deal_id', $dealId);
     Mage::app()->getRequest()->setParam('product', $productId);
     $observer = new Varien_Object();
     $buyRequest = new Varien_Object();
     $product = Mage::getModel('catalog/product')->load($productId);
     $buyRequest->setQty($qty);
     $observer->setBuyRequest($buyRequest);
     $observer->setProduct($product);
     /* set quote id and replace existing one in session */
     $quote = $this->getModelMock('sales/quote');
     $quoteItemsCollection = array();
     for ($i = 0; $i < $count; $i++) {
         $item = $this->getModelMock('sales/quote_item');
         $optionByCode = new Varien_Object();
         $optionByCode->setValue($infoBuyRequest);
         $item->expects($this->any())->method('getOptionByCode')->will($this->returnValue($optionByCode));
         $item->expects($this->any())->method('getQty')->will($this->returnValue(1));
         $quoteItemsCollection[] = $item;
     }
     $quote->expects($this->any())->method('getId')->will($this->returnValue(1));
     $quote->expects($this->any())->method('getItemsCollection')->will($this->returnValue($quoteItemsCollection));
     Mage::getSingleton('checkout/session')->replaceQuote($quote);
     if ($uid == '002') {
         $this->setExpectedException('Mage_Checkout_Exception');
     }
     Mage::getModel('collpur/observer')->prepareCart($observer);
 }
开发者ID:bigtailbear14,项目名称:rosstheme,代码行数:38,代码来源:Observer.php

示例2: configureAction

 public function configureAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     $quoteItem = null;
     $cart = $this->_getCart();
     if ($id) {
         $quoteItem = $cart->getQuote()->getItemById($id);
     }
     if (!$quoteItem) {
         $this->_getSession()->addError($this->__('Quote item is not found.'));
         $this->_redirect('checkout/cart');
         return;
     }
     try {
         $params = new Varien_Object();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $params->setBuyRequest($quoteItem->getBuyRequest());
         $id = $quoteItem->getProduct()->getId();
         $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($id);
         if (is_array($parentIds) && count($parentIds)) {
             $id = current($parentIds);
         }
         Mage::helper('catalog/product_view')->prepareAndRender($id, $this, $params);
     } catch (Exception $e) {
         $this->_getSession()->addError($this->__('Cannot configure product.'));
         Mage::logException($e);
         $this->_goBack();
         return;
     }
 }
开发者ID:Emulator000,项目名称:magento-configurable-simple,代码行数:31,代码来源:CartController.php

示例3: viewformAction

 public function viewformAction()
 {
     // Prepare data
     $configureResult = new Varien_Object();
     try {
         $orderItemId = (int) $this->getRequest()->getParam('item_id');
         if (!$orderItemId) {
             Mage::throwException($this->__('Quote item id is not received.'));
         }
         $orderItem = Mage::getModel('sales/order_item')->load($orderItemId);
         if (!$orderItem->getId()) {
             Mage::throwException($this->__('Quote item is not loaded.'));
         }
         $configureResult->setOk(true);
         $configureResult->setBuyRequest($orderItem->getBuyRequest());
         $configureResult->setCurrentStoreId($orderItem->getStoreId());
         $configureResult->setProductId($orderItem->getProductId());
     } catch (Exception $e) {
         $configureResult->setError(true);
         $configureResult->setMessage($e->getMessage());
     }
     // Render page
     /* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
     $helper = Mage::helper('spacemariachi_custopt');
     $helper->renderConfigureResult($this, $configureResult);
     return $this;
 }
开发者ID:ftorresarr,项目名称:spacemariachi_customoptions,代码行数:27,代码来源:EditoptionsController.php

示例4: configureAction

 /**
  * Action to reconfigure cart item
  * Modified to allow configuration of simple items assigned to configurables.
  */
 public function configureAction()
 {
     // Extract item and product to configure
     $id = (int) $this->getRequest()->getParam('id');
     $quoteItem = null;
     $cart = $this->_getCart();
     if ($id) {
         $quoteItem = $cart->getQuote()->getItemById($id);
     }
     $productId = $quoteItem->getProduct()->getId();
     //Check to see if this is a simple assigned to a configurable.
     if ($quoteItem->getOptionByCode('cpid')) {
         $cpid = $quoteItem->getOptionByCode('cpid')->getValue();
         $productId = (int) $cpid;
     }
     if (!$quoteItem) {
         $this->_getSession()->addError($this->__('Quote item is not found.'));
         $this->_redirect('checkout/cart');
         return;
     }
     try {
         $params = new Varien_Object();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $params->setBuyRequest($quoteItem->getBuyRequest());
         Mage::helper('catalog/product_view')->prepareAndRender($productId, $this, $params);
     } catch (Exception $e) {
         $this->_getSession()->addError($this->__('Cannot configure product: ' . $quoteItem->getProduct()->getId()));
         Mage::logException($e);
         $this->_goBack();
         return;
     }
 }
开发者ID:xiaoguizhidao,项目名称:tyler-live,代码行数:37,代码来源:CartController.php

示例5: configureAction

 /**
  * Ajax handler to response configuration fieldset of composite product in customer's wishlist
  *
  * @return Mage_Adminhtml_Customer_Wishlist_Product_Composite_WishlistController
  */
 public function configureAction()
 {
     $configureResult = new Varien_Object();
     try {
         $this->_initData();
         $configureResult->setProductId($this->_wishlistItem->getProductId());
         $configureResult->setBuyRequest($this->_wishlistItem->getBuyRequest());
         $configureResult->setCurrentStoreId($this->_wishlistItem->getStoreId());
         $configureResult->setCurrentCustomerId($this->_wishlist->getCustomerId());
         $configureResult->setOk(true);
     } catch (Exception $e) {
         $configureResult->setError(true);
         $configureResult->setMessage($e->getMessage());
     }
     /* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
     $helper = Mage::helper('adminhtml/catalog_product_composite');
     $helper->renderConfigureResult($this, $configureResult);
     return $this;
 }
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:24,代码来源:WishlistController.php

示例6: configureQuoteItemsAction

 public function configureQuoteItemsAction()
 {
     // Prepare data
     $configureResult = new Varien_Object();
     try {
         $quoteItemId = (int) $this->getRequest()->getParam('id');
         if (!$quoteItemId) {
             Mage::throwException($this->__('Quote item id is not received.'));
         }
         $quoteItem = Mage::getModel('buyback/quote_item')->load($quoteItemId);
         if (!$quoteItem->getId()) {
             Mage::throwException($this->__('Quote item is not loaded.'));
         }
         $configureResult->setOk(true);
         $optionCollection = Mage::getModel('buyback/quote_item_option')->getCollection()->addItemFilter(array($quoteItemId));
         $quoteItem->setOptions($optionCollection->getOptionsByItem($quoteItem));
         $configureResult->setBuyRequest($quoteItem->getBuyRequest());
         $configureResult->setCurrentStoreId($quoteItem->getStoreId());
         $configureResult->setProductId($quoteItem->getProductId());
         $sessionQuote = Mage::getSingleton('adminhtml/session_quote');
         $configureResult->setCurrentCustomerId($sessionQuote->getCustomerId());
     } catch (Exception $e) {
         $configureResult->setError(true);
         $configureResult->setMessage($e->getMessage());
     }
     // Render page
     /* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
     $helper = Mage::helper('adminhtml/catalog_product_composite');
     $helper->renderConfigureResult($this, $configureResult);
     return $this;
 }
开发者ID:pcuervo,项目名称:gadfy,代码行数:31,代码来源:CreateController.php

示例7: configureAction

 /**
  * Action to reconfigure cart item
  */
 public function configureAction()
 {
     // Extract item and product to configure
     $id = (int) $this->getRequest()->getParam('id');
     $quoteItem = null;
     $cart = $this->_getCart();
     if ($id) {
         $quoteItem = $cart->getQuote()->getItemById($id);
     }
     if (!$quoteItem) {
         $this->_getSession()->addError($this->__('Quote item is not found.'));
         $this->_redirect('checkout/cart');
         return;
     }
     try {
         $params = new Varien_Object();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $params->setBuyRequest($quoteItem->getBuyRequest());
         Mage::helper('Mage_Catalog_Helper_Product_View')->prepareAndRender($quoteItem->getProduct()->getId(), $this, $params);
     } catch (Exception $e) {
         $this->_getSession()->addError($this->__('Cannot configure product.'));
         Mage::logException($e);
         $this->_goBack();
         return;
     }
 }
开发者ID:relue,项目名称:magento2,代码行数:30,代码来源:CartController.php

示例8: configureAction

 /**
  * Action to reconfigure wishlist item
  */
 public function configureAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     try {
         /* @var $item Mage_Wishlist_Model_Item */
         $item = Mage::getModel('wishlist/item');
         $item->loadWithOptions($id);
         if (!$item->getId()) {
             Mage::throwException($this->__('Cannot load wishlist item'));
         }
         $wishlist = $this->_getWishlist($item->getWishlistId());
         if (!$wishlist) {
             return $this->norouteAction();
         }
         Mage::register('wishlist_item', $item);
         $params = new Varien_Object();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $buyRequest = $item->getBuyRequest();
         if (!$buyRequest->getQty() && $item->getQty()) {
             $buyRequest->setQty($item->getQty());
         }
         if ($buyRequest->getQty() && !$item->getQty()) {
             $item->setQty($buyRequest->getQty());
             Mage::helper('wishlist')->calculate();
         }
         $params->setBuyRequest($buyRequest);
         Mage::helper('catalog/product_view')->prepareAndRender($item->getProductId(), $this, $params);
     } catch (Mage_Core_Exception $e) {
         Mage::getSingleton('customer/session')->addError($e->getMessage());
         $this->_redirect('*');
         return;
     } catch (Exception $e) {
         Mage::getSingleton('customer/session')->addError($this->__('Cannot configure product'));
         Mage::logException($e);
         $this->_redirect('*');
         return;
     }
 }
开发者ID:monarcmoso,项目名称:beta2,代码行数:42,代码来源:IndexController.php

示例9: configureAction

 /**
  * Action to reconfigure cart item
  */
 public function configureAction()
 {
     // Extract item and product to configure
     $id = (int) $this->getRequest()->getParam('id');
     $quoteItem = null;
     try {
         $cart = $this->_getCart();
         $quoteItem = $cart->getQuote()->getItemById($id);
         if (!$quoteItem) {
             $this->_message($this->__('Quote item is not found.'), self::MESSAGE_STATUS_ERROR);
             return;
         }
         $params = new Varien_Object();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $params->setBuyRequest($quoteItem->getBuyRequest());
         $productHelper = Mage::helper('catalog/product');
         $buyRequest = $params->getBuyRequest();
         /** @var $product Mage_Catalog_Model_Product */
         $product = $productHelper->initProduct($quoteItem->getProduct()->getId(), $this, $params);
         if ($buyRequest) {
             $productHelper->prepareProductOptions($product, $buyRequest);
         }
         if ($params->hasConfigureMode()) {
             $product->setConfigureMode($params->getConfigureMode());
         }
         $this->loadLayout(false);
         $this->getLayout()->getBlock('xmlconnect.catalog.product')->setProduct($product);
         $this->renderLayout();
     } catch (Exception $e) {
         $this->_message($this->__('Cannot configure product.'), self::MESSAGE_STATUS_ERROR);
         Mage::logException($e);
         return;
     }
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:38,代码来源:CartController.php

示例10: configureAction

 /**
  * Ajax handler to response configuration fieldset of composite product in customer's cart
  *
  * @return Mage_Adminhtml_Customer_Cart_Product_Composite_CartController
  */
 public function configureAction()
 {
     $configureResult = new Varien_Object();
     try {
         $this->_initData();
         $quoteItem = $this->_quoteItem;
         $optionCollection = Mage::getModel('Mage_Sales_Model_Quote_Item_Option')->getCollection()->addItemFilter($quoteItem);
         $quoteItem->setOptions($optionCollection->getOptionsByItem($quoteItem));
         $configureResult->setOk(true);
         $configureResult->setProductId($quoteItem->getProductId());
         $configureResult->setBuyRequest($quoteItem->getBuyRequest());
         $configureResult->setCurrentStoreId($quoteItem->getStoreId());
         $configureResult->setCurrentCustomer($this->_customer);
     } catch (Exception $e) {
         $configureResult->setError(true);
         $configureResult->setMessage($e->getMessage());
     }
     /* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
     $helper = Mage::helper('Mage_Adminhtml_Helper_Catalog_Product_Composite');
     $helper->renderConfigureResult($this, $configureResult);
     return $this;
 }
开发者ID:relue,项目名称:magento2,代码行数:27,代码来源:CartController.php

示例11: configureAction

 /**
  * Ajax handler to response configuration fieldset of composite product in customer's cart
  *
  * @return Mage_Adminhtml_Customer_Cart_Product_Composite_CartController
  */
 public function configureAction()
 {
     $configureResult = new Varien_Object();
     try {
         $this->_initData();
         $quoteItem = $this->_quoteItem;
         $optionCollection = Mage::getModel('sales/quote_item_option')->getCollection()->addItemFilter($quoteItem);
         $quoteItem->setOptions($optionCollection->getOptionsByItem($quoteItem));
         $configureResult->setOk(true);
         $configureResult->setProductId($quoteItem->getProductId());
         $configureResult->setBuyRequest($quoteItem->getBuyRequest());
         $configureResult->setCurrentStoreId($quoteItem->getStoreId());
         $configureResult->setCurrentCustomer($this->_customer);
     } catch (Exception $e) {
         $configureResult->setError(true);
         $configureResult->setMessage($e->getMessage());
     }
     /* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
     $helper = Mage::helper('adminhtml/catalog_product_composite');
     // During order creation in the backend admin has ability to add any products to order
     Mage::helper('catalog/product')->setSkipSaleableCheck(true);
     $helper->renderConfigureResult($this, $configureResult);
     return $this;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:29,代码来源:CartController.php

示例12: configureFailedAction

 /**
  * Configure failed item options
  *
  * @return void
  */
 public function configureFailedAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     $qty = $this->getRequest()->getParam('qty', 1);
     try {
         $params = new Varien_Object();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $buyRequest = new Varien_Object(array('product' => $id, 'qty' => $qty));
         $params->setBuyRequest($buyRequest);
         Mage::helper('catalog/product_view')->prepareAndRender($id, $this, $params);
     } catch (Mage_Core_Exception $e) {
         $this->_getCustomerSession()->addError($e->getMessage());
         $this->_redirect('*');
         return;
     } catch (Exception $e) {
         $this->_getCustomerSession()->addError($this->__('Cannot configure product'));
         Mage::logException($e);
         $this->_redirect('*');
         return;
     }
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:27,代码来源:CartController.php

示例13: editAction

 public function editAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     $quoteItem = null;
     $cart = $this->_getCart();
     if ('POST' != $this->getRequest()->getMethod()) {
         if ($id) {
             $quoteItem = $cart->getQuote()->getItemById($id);
         }
         if (!$quoteItem) {
             $this->_getSession()->addError(Mage::helper('checkout')->__('Quote item is not found.'));
             $this->_goBack();
             return;
         }
         try {
             $params = new Varien_Object();
             $params->setCategoryId(false);
             $params->setConfigureMode(true);
             $params->setBuyRequest($quoteItem->getBuyRequest());
             Mage::helper('icart/catalog_product_view')->prepareAndRender($quoteItem->getProduct()->getId(), $this, $params);
         } catch (Exception $e) {
             $this->_getSession()->addError(Mage::helper('checkout')->__('Cannot configure product.'));
             Mage::logException($e);
             $this->_goBack();
             return;
         }
         return;
     }
     $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(Mage::helper('checkout')->__('Quote item is not found.'));
         }
         if (isset($params['qty']) && $params['qty'] == 0) {
             $isRemoveItemFlag = true;
             $cart->removeItem($id);
         } else {
             $isRemoveItemFlag = false;
             $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()) {
                 if ($isRemoveItemFlag) {
                     $message = Mage::helper('icart')->__('%s was deleted form your shopping cart.', Mage::helper('core')->htmlEscape($quoteItem->getName()));
                 } else {
                     $message = Mage::helper('checkout')->__('%s was updated in your shopping cart.', Mage::helper('core')->htmlEscape($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);
             }
         }
         $this->getRequest()->setParam('error', 1);
     } catch (Exception $e) {
         $this->_getSession()->addException($e, Mage::helper('checkout')->__('Cannot update the item.'));
         Mage::logException($e);
         $this->getRequest()->setParam('error', 1);
     }
     $this->_forward('added');
 }
开发者ID:xiaoguizhidao,项目名称:tyler-live,代码行数:89,代码来源:IndexController.php

示例14: loadOptionsAction

 public function loadOptionsAction()
 {
     $result = array();
     try {
         $alertError = Mage::getSingleton('core/session')->getMiniCartAlertError(true);
         // Get initial data from request
         $categoryId = (int) $this->getRequest()->getParam('category', false);
         $params = new Varien_Object();
         $params->setCategoryId($categoryId);
         $params->setSpecifyOptions($this->getRequest()->getParam('options'));
         $finalPrice = null;
         $qty = null;
         if ($this->getRequest()->getParam('item_id')) {
             /** @var $quote Mage_Sales_Model_Quote */
             $quote = Mage::getSingleton('checkout/session')->getQuote();
             /** @var $item Mage_Sales_Model_Quote_Item */
             $item = $quote->getItemById($this->getRequest()->getParam('item_id'));
             if (!$item->getId()) {
                 throw new Exception('Product is not loaded');
             }
             $item->setQuote(Mage::getSingleton('checkout/session')->getQuote());
             $productId = $item->getProduct()->getId();
             $params->setBuyRequest($item->getBuyRequest());
             $finalPrice = Mage::helper('tax')->displayCartPriceInclTax() ? Mage::helper('checkout')->getPriceInclTax($item) : $item->getCalculationPrice();
             $qty = $item->getTotalQty();
         } else {
             $productId = $this->getRequest()->getParam('product_id');
             if (!$productId) {
                 $requestPath = $this->getRequest()->getParam('request_path');
                 if (is_numeric($requestPath)) {
                     $productId = $requestPath;
                 } else {
                     $productId = (int) $this->_getProductIdByRequestPath($requestPath);
                 }
             }
         }
         /** @var $productHelper Mage_Catalog_Helper_Product */
         $productHelper = Mage::helper('catalog/product');
         if (method_exists($productHelper, 'initProduct')) {
             $product = $productHelper->initProduct($productId, $this, $params);
         } else {
             $this->getRequest()->setParam('id', $productId);
             $product = $this->_initProduct();
         }
         if (!$product) {
             throw new Exception('Product is not loaded');
         }
         $buyRequest = $params->getBuyRequest();
         if ($buyRequest) {
             $productHelper->prepareProductOptions($product, $buyRequest);
         }
         Mage::dispatchEvent('catalog_controller_product_view', array('product' => $product));
         if (method_exists($productHelper, 'initProduct')) {
             Mage::helper('catalog/product_view')->initProductLayout($product, $this);
         } else {
             $this->_initProductLayout($product);
         }
         if ($product->getTypeId() == 'grouped') {
             $viewBlockGrouped = $this->getLayout()->getBlock('product.info.grouped');
             $html = $viewBlockGrouped->toHtml();
             if ($this->getDataHelper()->isEnabledGroupedConfiguration()) {
                 $html .= '<script type="text/javascript">optionsPrice = {};if(typeof tierPriceElement == \'undefined\'){tierPriceElement = {update:function(){}};}</script>';
                 $html .= '<div id="product_addtocart_form"></div>';
                 $html .= str_replace('var optionsPrice', 'optionsPrice', $this->getLayout()->getBlock('grouped_product_edit')->toHtml());
                 $html = str_replace('var bundle', 'bundle', $html);
             }
         } else {
             $additionalJs = '';
             $optionsBlock = $this->getLayout()->getBlock('product.info.options.wrapper');
             $viewBlock = $this->getLayout()->getBlock('product.info');
             if ($product->getTypeId() == 'bundle') {
                 $viewBlockBundle = $this->getLayout()->getBlock('product.info.bundle');
                 $additionalJs = "taxCalcMethod = '" . Mage::helper('tax')->getConfig()->getAlgorithm($product->getStore()) . "';";
                 $additionalJs .= "CACL_UNIT_BASE = '" . Mage_Tax_Model_Calculation::CALC_UNIT_BASE . "';";
                 $additionalJs .= "CACL_ROW_BASE = '" . Mage_Tax_Model_Calculation::CALC_ROW_BASE . "';";
                 $additionalJs .= "CACL_TOTAL_BASE = '" . Mage_Tax_Model_Calculation::CALC_TOTAL_BASE . "';";
                 $additionalJs .= 'optionsPrice.tierPrices = [];bundle = new Product.Bundle(' . $viewBlockBundle->getJsonConfig() . ');';
                 $additionalJs .= "if(typeof Itoris.BundlePromotions == 'undefined'){Itoris.BundlePromotions = Class.create();}";
             }
             $html = '<script type="text/javascript">';
             $html .= 'optionsPrice = new MiniCartProductOptionsPrice(' . $viewBlock->getJsonConfig() . ');';
             $html .= $additionalJs . '</script>';
             if ($product->getHasOptions() || $product->getTypeId() != 'simple') {
                 $calendar = Mage::app()->getLayout()->createBlock('core/html_calendar')->setTemplate('page/js/calendar.phtml');
                 $html .= $calendar->toHtml() . $optionsBlock->toHtml();
             }
         }
         if ($this->getDataHelper()->isEnabledDynamicProductOptions()) {
             $html = $this->_addDynamicOptionsHtml($html);
         }
         $result = array('content' => $html, 'product_name' => $product->getName(), 'product_id' => $product->getId(), 'product_type' => $product->getTypeId(), 'price' => Mage::app()->getStore()->formatPrice($finalPrice ? $finalPrice : Mage::helper('tax')->getPrice($product, $product->getFinalPrice()), false), 'qty' => $qty ? (int) $qty : 1, 'alert_error' => $alertError);
     } catch (Exception $e) {
         $result['error'] = 'Product has not been loaded';
     }
     $this->getResponse()->setBody(Zend_Json::encode($result));
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:96,代码来源:ProductController.php

示例15: checkoutCartConfigure

 public function checkoutCartConfigure($observer)
 {
     $action = $observer->getEvent()->getControllerAction();
     if ($action->getRequest()->getParam('iswebposcart') == 'true') {
         $id = (int) $action->getRequest()->getParam('id');
         $quoteItem = null;
         $cart = $this->_getCart();
         if ($id) {
             $quoteItem = $cart->getQuote()->getItemById($id);
         }
         $result = array();
         if (!$quoteItem) {
             $action->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
             return $action->getResponse()->setBody('');
         }
         $viewHelper = Mage::helper('catalog/product_view');
         $params = new Varien_Object();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $params->setBuyRequest($quoteItem->getBuyRequest());
         $productHelper = Mage::helper('catalog/product');
         $productId = $quoteItem->getProduct()->getId();
         try {
             $product = $productHelper->initProduct($productId, $action, $params);
             if (!$product) {
                 $this->_getSession()->addError($viewHelper->__('Product is not loaded'));
             } else {
                 if ($buyRequest = $params->getBuyRequest()) {
                     $productHelper->prepareProductOptions($product, $buyRequest);
                 }
                 $product->setConfigureMode(true);
                 Mage::dispatchEvent('catalog_controller_product_view', array('product' => $product));
                 $viewHelper->initProductLayout($product, $action);
                 $result['hasOptions'] = true;
                 /* Daniel - doesn't allow add out of stock product to cart */
                 if (!$product->isAvailable()) {
                     $result['outofstock'] = true;
                 }
                 /* end */
             }
         } catch (Exception $e) {
             $this->_getSession()->addError(Mage::helper('checkout')->__('Cannot configure product.'));
         }
         $action->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
         $params = $action->getRequest()->getParams();
         try {
             if (isset($params['groupmessage']) && $action->getLayout()->getMessagesBlock()) {
                 $action->getLayout()->getMessagesBlock()->addMessages($this->_getSession()->getMessages(true));
                 $action->getLayout()->getMessagesBlock()->setEscapeMessageFlag($this->_getSession()->getEscapeMessages(true));
                 $result['message'] = $action->getLayout()->getMessagesBlock()->getGroupedHtml();
             } else {
                 $this->_getSession()->getMessages(true);
                 $this->_getSession()->getEscapeMessages(true);
             }
             if (isset($result['hasOptions'])) {
                 if ($typeBlock = Mage::getStoreConfig("webpos/product/{$product->getTypeId()}")) {
                     $productBlock = $action->getLayout()->createBlock($typeBlock, 'ajaxcart_product_view');
                 } else {
                     $productBlock = $action->getLayout()->createBlock('webpos/product_view', 'ajaxcart_product_view');
                 }
                 $productBlock->setData('submit_route_data', array('route' => 'checkout/cart/updateItemOptions', 'params' => array('id' => $id)));
                 /* add all js
                 			$result['optionjs'] = $productBlock->getJsItems();
                 			*/
                 /* Daniel - updated - js from colorselectorplus */
                 $optionjss = array();
                 /* add js from other extensions - for example: 
                 			$optionjss[] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS).'cjm/colorselectorplus/colorselected.js';
                 			$optionjss[] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);.'js/colorselectorplus/colorselected.js';
                 			*/
                 $result['optionjs'] = $optionjss;
                 /* end */
                 $result['optionhtml'] = $productBlock->toHtml();
             }
         } catch (Exception $e) {
         }
         $action->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
     }
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:79,代码来源:Cart.php


注:本文中的Varien_Object::setBuyRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。