/** * {@inheritdoc} */ protected function processEntity($entity, $isFullData = false, $isPersistNew = false, $itemData = null, array $searchContext = []) { $excluded = []; if (!$entity->getName()) { // do not update name if it's empty, due to bug in magento API $excluded = ['name']; } return $this->doctrineHelper->findAndReplaceEntity($entity, MagentoConnectorInterface::REGION_TYPE, 'combinedCode', $excluded); }
/** * @param AbstractAddress $address * @param string $countryCode * * @throws InvalidItemException * @return Country|null */ public function getAddressCountryByCode(AbstractAddress $address, $countryCode) { if (!$address->getCountry()) { return null; } if (array_key_exists($countryCode, $this->countriesCache)) { if (!empty($this->countriesCache[$countryCode])) { $this->countriesCache[$countryCode] = $this->doctrineHelper->merge($this->countriesCache[$countryCode]); } } else { /** @var Country $country */ $country = $this->doctrineHelper->findAndReplaceEntity($address->getCountry(), 'Oro\\Bundle\\AddressBundle\\Entity\\Country', 'iso2Code', ['iso2Code', 'iso3Code', 'name']); $this->countriesCache[$countryCode] = $country->getIso2Code() ? $country : null; } return $this->countriesCache[$countryCode]; }
/** * @param mixed $entity New entity * @param string $entityName Class name * @param string|array $criteria Field name to find existing entity * @param array $excludedProperties Excluded properties * * @return mixed */ protected function findAndReplaceEntity($entity, $entityName, $criteria = 'id', $excludedProperties = []) { return $this->doctrineHelper->findAndReplaceEntity($entity, $entityName, $criteria, $excludedProperties); }