Esempio n. 1
0
 /**
  * @param string $email
  * @return bool|\Magento\Customer\Model\Customer
  */
 public function getCustomerByEmail($email)
 {
     /** @var \Magento\Customer\Model\Customer $customer */
     $customer = $this->customerFactory->create();
     $customer->setWebsiteId($this->storeManager->getWebsiteId());
     $customer->loadByEmail($email);
     if ($customer->getId()) {
         return $customer;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * @return array
  */
 protected function getDefaultCustomerProfile()
 {
     if (!$this->customerDataProfile) {
         $this->customerDataProfile = ['website_id' => $this->storeManager->getWebsiteId(), 'group_id' => $this->storeManager->getGroupId(), 'disable_auto_group_change' => '0', 'prefix', 'firstname' => '', 'middlename' => '', 'lastname' => '', 'suffix' => '', 'email' => '', 'dob' => '', 'taxvat' => '', 'gender' => '', 'confirmation' => false, 'sendemail' => false];
     }
     return $this->customerDataProfile;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->logger->log("Installing {$this->productType} products:");
     $product = $this->productFactory->create();
     foreach ($this->fixtures as $file) {
         /** @var \Magento\Tools\SampleData\Helper\Csv\Reader $csvReader */
         $fileName = $this->fixtureHelper->getPath($file);
         $csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']);
         foreach ($csvReader as $row) {
             $attributeSetId = $this->catalogConfig->getAttributeSetId(4, $row['attribute_set']);
             $this->converter->setAttributeSetId($attributeSetId);
             $data = $this->converter->convertRow($row);
             $product->unsetData();
             $product->setData($data);
             $product->setTypeId($this->productType)->setAttributeSetId($attributeSetId)->setWebsiteIds([$this->storeManager->getWebsiteId()])->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)->setStockData(['is_in_stock' => 1, 'manage_stock' => 0])->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID);
             if (empty($data['visibility'])) {
                 $product->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH);
             }
             $this->prepareProduct($product, $data);
             $product->save();
             $this->gallery->install($product);
             $this->logger->logInline('.');
         }
     }
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->logger->log('Installing Tablerate:');
     /** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
     $adapter = $this->resource->getConnection('core_write');
     $fixtureFile = 'OfflineShipping/tablerate.csv';
     $fixtureFilePath = $this->fixtureHelper->getPath($fixtureFile);
     $regions = $this->loadDirectoryRegions();
     /** @var \Magento\Tools\SampleData\Helper\Csv\Reader $csvReader */
     $csvReader = $this->csvReaderFactory->create(['fileName' => $fixtureFilePath, 'mode' => 'r']);
     foreach ($csvReader as $data) {
         $regionId = $data['region'] != '*' ? $regions[$data['country']][$data['region']] : 0;
         $adapter->insert($this->tablerate->getMainTable(), ['website_id' => $this->storeManager->getWebsiteId(), 'dest_country_id' => $data['country'], 'dest_region_id' => $regionId, 'dest_zip' => $data['zip'], 'condition_name' => 'package_value', 'condition_value' => $data['order_subtotal'], 'price' => $data['price'], 'cost' => 0]);
         $this->logger->logInline('.');
     }
     $this->configWriter->save('carriers/tablerate/active', 1);
     $this->configWriter->save('carriers/tablerate/condition_name', 'package_value');
     $this->cacheTypeList->cleanType('config');
 }
Esempio n. 5
0
 /**
  * @param array $orderData
  * @return void
  */
 public function createOrder($orderData)
 {
     $this->setPhraseRenderer();
     if (!empty($orderData)) {
         $orderCreateModel = $this->processQuote($orderData);
         if (!empty($orderData['payment'])) {
             $orderCreateModel->setPaymentData($orderData['payment']);
             $orderCreateModel->getQuote()->getPayment()->addData($orderData['payment']);
         }
         $customer = $this->customerRepository->get($orderData['order']['account']['email'], $this->storeManager->getWebsiteId());
         $orderCreateModel->getQuote()->setCustomer($customer);
         $orderCreateModel->getSession()->setCustomerId($customer->getId());
         $order = $orderCreateModel->importPostData($orderData['order'])->createOrder();
         $orderItem = $this->getOrderItemForTransaction($order);
         $this->invoiceOrder($orderItem);
         $this->shipOrder($orderItem);
         if ($orderData['refund'] === "yes") {
             $this->refundOrder($orderItem);
         }
         $registryItems = ['rule_data', 'currently_saved_addresses', 'current_invoice', 'current_shipment'];
         $this->unsetRegistryData($registryItems);
     }
 }