/** * Prepares and render result of composite product configuration request * * $configureResult holds either: * - 'ok' = true, and 'product_id', 'buy_request', 'current_store_id', 'current_customer' or 'current_customer_id' * - 'error' = true, and 'message' to show * * @param Mage_Adminhtml_Controller_Action $controller * @param Varien_Object $configureResult * @return Mage_Adminhtml_Helper_Catalog_Product_Composite */ public function renderConfigureResult($controller, Varien_Object $configureResult) { try { if (!$configureResult->getOk()) { Mage::throwException($configureResult->getMessage()); } $currentStoreId = (int) $configureResult->getCurrentStoreId(); if (!$currentStoreId) { $currentStoreId = Mage::app()->getStore()->getId(); } $product = Mage::getModel('catalog/product')->setStoreId($currentStoreId)->load($configureResult->getProductId()); if (!$product->getId()) { Mage::throwException($this->__('Product is not loaded.')); } Mage::register('current_product', $product); Mage::register('product', $product); // Register customer we're working with $currentCustomer = $configureResult->getCurrentCustomer(); if (!$currentCustomer) { $currentCustomerId = (int) $configureResult->getCurrentCustomerId(); if ($currentCustomerId) { $currentCustomer = Mage::getModel('customer/customer')->load($currentCustomerId); } } if ($currentCustomer) { Mage::register('current_customer', $currentCustomer); } // Prepare buy request values $buyRequest = $configureResult->getBuyRequest(); if ($buyRequest) { Mage::helper('catalog/product')->prepareProductOptions($product, $buyRequest); } $isOk = true; $productType = $product->getTypeId(); } catch (Exception $e) { $isOk = false; $productType = null; Mage::register('composite_configure_result_error_message', $e->getMessage()); } $this->_initConfigureResultLayout($controller, $isOk, $productType); $controller->renderLayout(); }