<?php
 namespace App\ImportedOrder\PopulateEntity; class SupplierProduct extends GeneralAbstract { protected $importedEntity; protected $importedEntityClass = '\App\ImportedOrder\SupplierProduct'; protected $populatingEntityClass = '\Entity\SupplierProduct'; public function populate() { if ($this->populatingEntity->getOperation()=='insert') { if ($this->importedEntity->serviceType) { $matchedServiceCode = $this->importedEntity->serviceType->getMatchedId($this->idExternalSystem); if ($matchedServiceCode) { $this->populatingEntity->serviceCode = $matchedServiceCode; } } } if ($this->importedEntity->name!==null) { $this->populatingEntity->productName = htmlClean($this->importedEntity->name); } if ($this->importedEntity->groupName!==null) { $this->populatingEntity->chainCode = $this->importedEntity->groupName; } if ($this->importedEntity->categoryCode!==null) { $this->populatingEntity->category = $this->importedEntity->categoryCode; } if ($this->importedEntity->address!==null) { $this->populatingEntity->address = htmlClean($this->importedEntity->address); } if ($this->importedEntity->telephone!==null) { $this->populatingEntity->telephone = $this->importedEntity->telephone; } if ($this->importedEntity->fax!==null) { $this->populatingEntity->fax = $this->importedEntity->fax; } if ($this->importedEntity->email!==null) { $this->populatingEntity->email = $this->importedEntity->email; } if ($this->importedEntity->place) { $importedStation = $this->importedEntity->place->station; if ($importedStation) { $importedCity = $importedStation->city; if ($importedCity) { $matchedCityId = $importedCity->getMatchedId($this->idExternalSystem); if ($matchedCityId) { $this->populatingEntity->destinationCityId = $matchedCityId; $this->populatingEntity->destinationCountryCode = \Entity\City::select($matchedCityId)->countryCode; } else { $importedCountry = $importedCity->country; if ($importedCountry) { $matchedCountryCode = $importedCountry->getMatchedId($this->idExternalSystem); if ($matchedCountryCode) { $this->populatingEntity->destinationCityId = 0; $this->populatingEntity->destinationCountryCode = $matchedCountryCode; } } } } } } } }