public function init() { if ($this->isInitialized) { return; } $this->isInitialized = true; if ($this->config->get('CHECKOUT_METHOD') == 'CHECKOUT_MULTISTEP') { return new ActionRedirectResponse('checkout', 'index'); } $this->isTosRequired = $this->config->get('REQUIRE_TOS'); parent::init(); $this->config->setRuntime('CHECKOUT_CUSTOM_FIELDS', self::CUSTOM_FIELDS_STEP); $this->config->setRuntime('ENABLE_CHECKOUTDELIVERYSTEP', true); $this->config->setRuntime('DISABLE_CHECKOUT_ADDRESS_STEP', false); $this->config->setRuntime('DISABLE_GUEST_CHECKOUT', false); $this->config->setRuntime('ENABLE_SHIPPING_ESTIMATE', false); $this->config->setRuntime('SKIP_SHIPPING', false); $this->config->setRuntime('SKIP_PAYMENT', false); $this->config->setRuntime('REG_EMAIL_CONFIRM', false); $this->config->setRuntime('EMAIL_NEW_USER', false); $this->config->setRuntime('REQUIRE_TOS', false); $this->loadLanguageFile('Order'); $this->loadLanguageFile('User'); $this->order->loadSpecification(); ActiveRecordModel::loadEav(); if ($this->user->isAnonymous()) { if ($this->session->get('checkoutUser')) { $checkoutUser = unserialize($this->session->get('checkoutUser')); $checkoutUser->setID(null); SessionUser::setUser($checkoutUser); if ($this->user !== $checkoutUser && $checkoutUser instanceof User) { $this->user = $checkoutUser; } } $this->user->grantAccess('login'); $this->setAnonAddresses(); $this->order->user->set($this->user); $this->order->shippingAddress->resetModifiedStatus(); $this->order->billingAddress->resetModifiedStatus(); $this->order->user->resetModifiedStatus(); } else { $this->user->load(); $this->user->loadAddresses(); $address = $this->user->defaultShippingAddress->get(); if (!$address) { $address = $this->user->defaultBillingAddress->get(); } if (!$this->order->shippingAddress->get() && $address && $this->isShippingRequired($this->order)) { $userAddress = $address->userAddress->get(); $this->order->shippingAddress->set($userAddress); $this->order->save(); } $address = $this->user->defaultBillingAddress->get(); if (!$this->order->billingAddress->get() && $address) { $userAddress = $address->userAddress->get(); $this->order->billingAddress->set($userAddress); $this->order->save(); } } }
protected function processDataArray($dataArray, $displayedColumns) { // load specification data if ($this->isEav()) { foreach ($displayedColumns as $column => $type) { if (!strpos($column, '.')) { continue; } list($class, $field) = explode('.', $column, 2); if ('eavField' == $class) { ActiveRecordModel::addArrayToEavQueue($this->getClassName(), $dataArray); ActiveRecordModel::loadEav(); break; } } } return $dataArray; }
protected function postProcessResponse(Response $response, Controller $controllerInstance) { if (!$response instanceof Renderable || !$this->isInstalled()) { return false; } $response->set('user', $controllerInstance->getUser()->toArray()); $response->set('message', $controllerInstance->getMessage()); $response->set('errorMessage', $controllerInstance->getErrorMessage()); if ($controllerInstance instanceof FrontendController) { $response->set('currency', $controllerInstance->getRequestCurrency()); } // fetch queued EAV data if (class_exists('ActiveRecordModel', false)) { ActiveRecordModel::loadEav(); } $renderer = $this->getRenderer(); if ($response instanceof ActionResponse && !$controllerInstance->isBlocksProcessed) { $controllerInstance->isBlocksProcessed = true; foreach ($renderer->getBlockConfiguration() as $object => $commands) { foreach ($commands as $command) { if ($renderer->isBlock($object)) { $action = $command['action']; switch ($action['command']) { case 'replace': $action['command'] = 'append'; $controllerInstance->removeBlock($object); case 'append': case 'prepend': if (!empty($action['isDefinedBlock'])) { $action = array_merge($action, (array) array_shift($controllerInstance->getBlocks($action['view']))); } $controllerInstance->addBlock($object, $action['call'], $action['view'], $action['command'] == 'prepend'); break; case 'remove': $controllerInstance->removeBlock($object); break; case 'theme': $this->setTheme($action['view']); break; } } } } } }
public function testEavQueue() { // set up Manufacturer records $field = EavField::getNewInstance('Manufacturer', EavField::DATATYPE_TEXT, EavField::TYPE_TEXT_SIMPLE); $field->save(); $data = array('first', 'second', 'third'); foreach ($data as $value) { $manufacturer = Manufacturer::getNewInstance($value); $manufacturer->getSpecification()->setAttributeValueByLang($field, 'en', $value . ' test'); $manufacturer->save(); } ActiveRecordModel::clearPool(); // fetch them from database $manufacturers = ActiveRecordModel::getRecordSetArray('Manufacturer', new ARSelectFilter()); foreach ($manufacturers as &$entry) { ActiveRecordModel::addToEavQueue('Manufacturer', $entry); } // duplicate $manufacturers = array_merge($manufacturers, $manufacturers); // load EAV data ActiveRecordModel::loadEav(); foreach ($manufacturers as $man) { $this->assertEqual($man['name'] . ' test', $man['attributes'][$field->getID()]['value_en']); } }