Exemple #1
0
/**
 * 2016-01-11
 * @param bool $withDefault [optional]
 * @param bool $codeKey [optional]
 * @return array|\Magento\Store\Api\Data\StoreInterface[]
 */
function df_stores($withDefault = false, $codeKey = false)
{
    /**
     * 2016-01-29
     * Добави @uses df_ksort(), потому что иначе порядок элементов различается
     * в зависимости от того, загружается ли страница из кэша или нет.
     * Для модуля Dfe\SalesSequence нам нужен фиксированный порядок.
     */
    return df_ksort(df_store_m()->getStores($withDefault, $codeKey));
}
Exemple #2
0
 /**
  * 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]);
 }