/** * After generate Xml * * @param \Magento\Framework\View\LayoutInterface $subject * @param \Magento\Framework\View\LayoutInterface $result * @return \Magento\Framework\View\LayoutInterface */ public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result) { if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) { $this->visitor->setSkipRequestLogging(true); $this->visitor->unsetData(); $this->session->clearStorage(); $this->customerSession->clearStorage(); $this->session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->formKey); $this->customerSession->setCustomerGroupId($this->customerGroupId); $this->customer->setGroupId($this->customerGroupId); $this->customerSession->setCustomer($this->customer); } return $result; }
/** * 2015-10-12 * Регистрация нового клиента. * @param MC $customer * @return void */ private function register(MC $customer) { /** * 2015-10-12 * https://github.com/magento/magento2/issues/2087 * Приходится присваивать магазин в 2 шага... */ /** @var \Magento\Store\Api\Data\StoreInterface|\Magento\Store\Model\Store $store */ $store = df_store_m()->getStore(); $customer->setStore($store); $customer->setGroupId(df_customer_group_m()->getDefaultGroup($store->getId())->getId()); $customer->addData($this->customerData()); $customer->save(); /** * 2016-06-05 * Не всегда имеет смысл автоматически создавать адрес. * В частности, для Amazon решил этого не делать, * потому что автоматический адрес создаётся на основании геолокации, что не точно, * а в случае с Amazon мы гарантированно можем получить точный адрес из профиля Amazon, * поэтому нам нет никакого смысла забивать систему неточным автоматическим адресом. * @see \Dfe\AmazonLogin\Controller\Index\Index::needCreateAddress() */ if ($this->needCreateAddress()) { /** @var Address $address */ $address = df_om()->create(Address::class); $address->setCustomer($customer); $address->addData(df_clean($this->addressData() + ['firstname' => $this->c()->nameFirst(), 'lastname' => $this->c()->nameLast(), 'middlename' => $this->c()->nameMiddle(), 'city' => df_visitor()->city(), 'country_id' => df_visitor()->iso2(), 'is_default_billing' => 1, 'is_default_shipping' => 1, 'postcode' => df_visitor()->postCode() ?: (df_is_postcode_required(df_visitor()->iso2()) ? '000000' : null), 'region' => df_visitor()->regionName(), 'region_id' => null, 'save_in_address_book' => 1, 'street' => '---', 'telephone' => '000000'])); $address->save(); } df_dispatch('customer_register_success', ['account_controller' => $this, 'customer' => $customer]); }