/**
  * Retrieve generic object with all the misc store information values
  *
  * @param Store $store
  * @return DataObject
  */
 public function getStoreInformationObject(Store $store)
 {
     $info = new DataObject(['name' => $store->getConfig(self::XML_PATH_STORE_INFO_NAME), 'phone' => $store->getConfig(self::XML_PATH_STORE_INFO_PHONE), 'hours' => $store->getConfig(self::XML_PATH_STORE_INFO_HOURS), 'street_line1' => $store->getConfig(self::XML_PATH_STORE_INFO_STREET_LINE1), 'street_line2' => $store->getConfig(self::XML_PATH_STORE_INFO_STREET_LINE2), 'city' => $store->getConfig(self::XML_PATH_STORE_INFO_CITY), 'postcode' => $store->getConfig(self::XML_PATH_STORE_INFO_POSTCODE), 'region_id' => $store->getConfig(self::XML_PATH_STORE_INFO_REGION_CODE), 'country_id' => $store->getConfig(self::XML_PATH_STORE_INFO_COUNTRY_CODE), 'vat_number' => $store->getConfig(self::XML_PATH_STORE_INFO_VAT_NUMBER)]);
     if ($info->getRegionId()) {
         $info->setRegion($this->regionFactory->create()->load($info->getRegionId())->getName());
     }
     if ($info->getCountryId()) {
         $info->setCountry($this->countryFactory->create()->loadByCode($info->getCountryId())->getName());
     }
     return $info;
 }
Example #2
0
 /**
  * Set region to the attribute
  *
  * @param \Magento\Framework\DataObject $object
  * @return $this
  */
 public function beforeSave($object)
 {
     if (is_numeric($object->getRegion())) {
         $region = $this->_regionFactory->create()->load((int) $object->getRegion());
         if ($region) {
             $object->setRegionId($region->getId());
             $object->setRegion($region->getCode());
         }
     }
     return $this;
 }