From 70f3c01101a000fbbbacee1c864d90baf68aa79f Mon Sep 17 00:00:00 2001 From: Stefan Jaroschek Date: Fri, 5 May 2023 09:28:36 +0200 Subject: [PATCH 1/5] Add support for optional region address fields 'region_id' and 'region_code' --- .../CustomerAddressExportObserver.php | 6 +- src/Observers/CustomerAddressObserver.php | 20 ++++- src/Plugins/GlobalDataPlugin.php | 81 +++++++++++++++++++ .../CustomerAddressRepository.php | 30 +++++++ .../CustomerAddressRepositoryInterface.php | 7 ++ src/Repositories/SqlStatementRepository.php | 3 + .../CustomerAddressBunchProcessor.php | 8 ++ ...CustomerAddressBunchProcessorInterface.php | 7 ++ .../AbstractCustomerAddressSubject.php | 26 +++++- src/Utils/ColumnKeys.php | 21 +++++ src/Utils/MemberNames.php | 14 ++++ src/Utils/RegistryKeys.php | 7 ++ src/Utils/SqlStatementKeys.php | 7 ++ 13 files changed, 233 insertions(+), 4 deletions(-) create mode 100644 src/Plugins/GlobalDataPlugin.php diff --git a/src/Observers/CustomerAddressExportObserver.php b/src/Observers/CustomerAddressExportObserver.php index 8b3cf74..781c94d 100644 --- a/src/Observers/CustomerAddressExportObserver.php +++ b/src/Observers/CustomerAddressExportObserver.php @@ -96,7 +96,7 @@ protected function process() } // initialize the array for the links $artefacts = array(); - + $artefacts[] = $this->newArtefact( array( ColumnKeys::ENTITY_ID => $this->getValue(ColumnKeys::ENTITY_ID), @@ -114,6 +114,8 @@ protected function process() ColumnKeys::POSTCODE => $this->getValue(ColumnKeys::ADDRESS_POSTCODE), ColumnKeys::PREFIX => $this->getValue(ColumnKeys::ADDRESS_PREFIX), ColumnKeys::REGION => $this->getValue(ColumnKeys::ADDRESS_REGION), + ColumnKeys::REGION_CODE => $this->getValue(ColumnKeys::ADDRESS_REGION_CODE), + ColumnKeys::REGION_ID => $this->getValue(ColumnKeys::ADDRESS_REGION_ID), ColumnKeys::STREET => $addressStreet, ColumnKeys::SUFFIX => $this->getValue(ColumnKeys::ADDRESS_SUFFIX), ColumnKeys::TELEPHONE => $this->getValue(ColumnKeys::ADDRESS_TELEPHONE), @@ -137,6 +139,8 @@ protected function process() ColumnKeys::POSTCODE => ColumnKeys::ADDRESS_POSTCODE, ColumnKeys::PREFIX => ColumnKeys::ADDRESS_PREFIX, ColumnKeys::REGION => ColumnKeys::ADDRESS_REGION, + ColumnKeys::REGION_CODE => ColumnKeys::ADDRESS_REGION_CODE, + ColumnKeys::REGION_ID => ColumnKeys::ADDRESS_REGION_ID, ColumnKeys::STREET => ColumnKeys::ADDRESS_STREET, ColumnKeys::SUFFIX => ColumnKeys::ADDRESS_SUFFIX, ColumnKeys::TELEPHONE => ColumnKeys::ADDRESS_TELEPHONE, diff --git a/src/Observers/CustomerAddressObserver.php b/src/Observers/CustomerAddressObserver.php index 38656b3..64b41f6 100644 --- a/src/Observers/CustomerAddressObserver.php +++ b/src/Observers/CustomerAddressObserver.php @@ -122,7 +122,7 @@ protected function prepareAttributes() ); return []; } - + // initialize the customer values $entityId = $this->getValue(ColumnKeys::ENTITY_ID); $city = $this->getValue(ColumnKeys::CITY, ''); @@ -135,7 +135,13 @@ protected function prepareAttributes() $postcode = $this->getValue(ColumnKeys::POSTCODE); $prefix = $this->getValue(ColumnKeys::PREFIX); $region = $this->getValue(ColumnKeys::REGION); + $regionCode = $this->getValue(ColumnKeys::REGION_CODE); $regionId = $this->getValue(ColumnKeys::REGION_ID); + + if (empty($regionId) && !empty($regionCode)) { + $regionId = $this->getCountryRegionIdByCode($regionCode); + } + $street = $this->getValue(ColumnKeys::STREET, ''); $suffix = $this->getValue(ColumnKeys::SUFFIX); $telephone = $this->checkCustomerPhoneConfig($this->getValue(ColumnKeys::TELEPHONE, '')); @@ -305,6 +311,18 @@ protected function getStoreWebsiteIdByCode($code) return $this->getSubject()->getStoreWebsiteIdByCode($code); } + /** + * Return's the region ID for the given code, if it exists. + * + * @param string|null $code The code of the requested customer group + * + * @return integer|null The region ID + */ + protected function getCountryRegionIdByCode($code) + { + return $this->getSubject()->getCountryRegionIdByCode($code); + } + /** * @param string $value value of customer column * diff --git a/src/Plugins/GlobalDataPlugin.php b/src/Plugins/GlobalDataPlugin.php new file mode 100644 index 0000000..3e6b7d0 --- /dev/null +++ b/src/Plugins/GlobalDataPlugin.php @@ -0,0 +1,81 @@ + + * @copyright 2023 TechDivision GmbH + * @license https://opensource.org/licenses/MIT + * @link https://github.com/techdivision/import + * @link http://www.techdivision.com + */ +declare(strict_types=1); + +namespace TechDivision\Import\Customer\Address\Plugins; + +use TechDivision\Import\ApplicationInterface; +use TechDivision\Import\Customer\Address\Services\CustomerAddressBunchProcessorInterface; +use TechDivision\Import\Plugins\AbstractPlugin; +use TechDivision\Import\Customer\Address\Utils\RegistryKeys; + +/** + * Plugin that loads the global data. + * + * @author MET + * @copyright 2023 TechDivision GmbH + * @license https://opensource.org/licenses/MIT + * @link https://github.com/techdivision/import + * @link http://www.techdivision.com + */ +class GlobalDataPlugin extends AbstractPlugin +{ + /** + * @var CustomerAddressBunchProcessorInterface + */ + protected $customerAddressBunchProcessor; + + /** + * @param ApplicationInterface $application + * @param CustomerAddressBunchProcessorInterface $customerAddressBunchProcessor + */ + public function __construct( + ApplicationInterface $application, + CustomerAddressBunchProcessorInterface $customerAddressBunchProcessor + ){ + $this->customerAddressBunchProcessor = $customerAddressBunchProcessor; + parent::__construct($application); + } + + /** + * Process the plugin functionality. + * + * @return void + * @throws \Exception Is thrown, if the plugin can not be processed + */ + public function process() + { + // initialize the array for the global data + $globalData = array(); + + // initialize the global data + $globalData[RegistryKeys::COUNTRY_REGIONS] = $this->getCountryRegions(); + + $globalData = array_merge($this->getImportProcessor()->getGlobalData(), $globalData); + + // add the status with the global data + $this->getRegistryProcessor()->mergeAttributesRecursive( + RegistryKeys::STATUS, + array(RegistryKeys::GLOBAL_DATA => $globalData) + ); + } + + /** + * @return mixed + */ + public function getCountryRegions() + { + return $this->customerAddressBunchProcessor->loadDirectoryCountryRegions(); + } +} diff --git a/src/Repositories/CustomerAddressRepository.php b/src/Repositories/CustomerAddressRepository.php index 87233d8..dbd437b 100644 --- a/src/Repositories/CustomerAddressRepository.php +++ b/src/Repositories/CustomerAddressRepository.php @@ -51,6 +51,11 @@ class CustomerAddressRepository extends AbstractRepository implements CustomerAd */ protected $customerAddressIncrementIdStmt; + /** + * @var PDOStatement + */ + protected $directoryCountryRegionsStatement; + /** * Initializes the repository's prepared statements. * @@ -66,6 +71,8 @@ public function init() $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_ADDRESSES)); $this->customerAddressIncrementIdStmt = $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_ADDRESS_INCREMENT_ID)); + $this->directoryCountryRegionsStatement = + $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::SELECT_DIRECTORY_COUNTRY_REGION)); } /** @@ -114,4 +121,27 @@ public function loadByIncrementIdAndCustomerEntityId($incrementId, $customerId) ); return $this->customerAddressIncrementIdStmt->fetch(\PDO::FETCH_ASSOC); } + /** + * Return's all country regions from directory + * + * @return array + */ + public function findDirectoryCountryRegions() + { + $directoryCountryRegions = []; + + // execute the prepared statement + $this->directoryCountryRegionsStatement->execute(); + + // load the available customer groups + $avalaibleDirectoryCountryRegions = $this->directoryCountryRegionsStatement->fetchAll(); + + // fetch the directory regions and assemble them as array with the codes as key + foreach ($avalaibleDirectoryCountryRegions as $countryRegion) { + $directoryCountryRegions[$countryRegion[MemberNames::DIRECTORY_REGION_CODE]] = $countryRegion; + } + + // return the customer groups + return $directoryCountryRegions; + } } diff --git a/src/Repositories/CustomerAddressRepositoryInterface.php b/src/Repositories/CustomerAddressRepositoryInterface.php index 0148eff..c7f5628 100644 --- a/src/Repositories/CustomerAddressRepositoryInterface.php +++ b/src/Repositories/CustomerAddressRepositoryInterface.php @@ -53,4 +53,11 @@ public function load($id); * @return array|null The customer */ public function loadByIncrementIdAndCustomerEntityId($incrementId, $customerId); + + /** + * Return's all country regions from directory + * + * @return array + */ + public function findDirectoryCountryRegions(); } diff --git a/src/Repositories/SqlStatementRepository.php b/src/Repositories/SqlStatementRepository.php index 3cdf689..4e5902a 100644 --- a/src/Repositories/SqlStatementRepository.php +++ b/src/Repositories/SqlStatementRepository.php @@ -251,6 +251,9 @@ class SqlStatementRepository extends \TechDivision\Import\Repositories\SqlStatem 'DELETE FROM ${table:customer_address_entity_text} WHERE value_id = :value_id', + SqlStatementKeys::SELECT_DIRECTORY_COUNTRY_REGION => + 'SELECT * + FROM ${table:directory_country_region}', ); /** diff --git a/src/Services/CustomerAddressBunchProcessor.php b/src/Services/CustomerAddressBunchProcessor.php index 9864918..c04f9b3 100755 --- a/src/Services/CustomerAddressBunchProcessor.php +++ b/src/Services/CustomerAddressBunchProcessor.php @@ -592,6 +592,14 @@ public function loadCustomerByEmailAndWebsiteId($email, $websiteId) return $this->getCustomerRepository()->findOneByEmailAndWebsiteId($email, $websiteId); } + /** + * @return mixed + */ + public function loadDirectoryCountryRegions() + { + return $this->getCustomerAddressRepository()->findDirectoryCountryRegions(); + } + /** * Persist's the passed customer address data and return's the ID. * diff --git a/src/Services/CustomerAddressBunchProcessorInterface.php b/src/Services/CustomerAddressBunchProcessorInterface.php index 866499e..64c853d 100644 --- a/src/Services/CustomerAddressBunchProcessorInterface.php +++ b/src/Services/CustomerAddressBunchProcessorInterface.php @@ -142,6 +142,13 @@ public function loadCustomerAddress($id); */ public function loadCustomerByEmailAndWebsiteId($email, $websiteId); + /** + * Return's all country regions from directory + * + * @return array + */ + public function loadDirectoryCountryRegions(); + /** * Persist's the passed customer address data and return's the ID. * diff --git a/src/Subjects/AbstractCustomerAddressSubject.php b/src/Subjects/AbstractCustomerAddressSubject.php index d2f1242..d6942a3 100644 --- a/src/Subjects/AbstractCustomerAddressSubject.php +++ b/src/Subjects/AbstractCustomerAddressSubject.php @@ -33,6 +33,13 @@ abstract class AbstractCustomerAddressSubject extends AbstractEavSubject implements EntitySubjectInterface { + /** + * The available country regions. + * + * @var array + */ + protected $countryRegions = array(); + /** * The ID of the product that has been created recently. * @@ -95,8 +102,11 @@ public function setUp($serial) // load the status of the actual import $status = $this->getRegistryProcessor()->getAttribute(RegistryKeys::STATUS); - // load the global data we've prepared initially - $this->storeWebsites = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::STORE_WEBSITES]; + if (isset($status[RegistryKeys::GLOBAL_DATA])) { + // load the global data we've prepared initially + $this->storeWebsites = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::STORE_WEBSITES]; + $this->countryRegions = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::COUNTRY_REGIONS]; + } // invoke the parent method parent::setUp($serial); @@ -126,6 +136,18 @@ public function getStoreWebsiteIdByCode($code) ); } + /** + * @param string $code + * @return integer|null + */ + public function getCountryRegionIdByCode($code) + { + if (isset($this->countryRegions[$code])) { + return (integer)$this->countryRegions[$code][MemberNames::REGION_ID]; + } + return null; + } + /** * Merge the columns from the configuration with all image type columns to define which * columns should be cleaned-up. diff --git a/src/Utils/ColumnKeys.php b/src/Utils/ColumnKeys.php index 2a24c56..978283f 100644 --- a/src/Utils/ColumnKeys.php +++ b/src/Utils/ColumnKeys.php @@ -82,6 +82,13 @@ class ColumnKeys extends \TechDivision\Import\Customer\Utils\ColumnKeys */ const REGION = 'region'; + /** + * Name for the column 'region_code'. + * + * @var string + */ + const REGION_CODE = 'region_code'; + /** * Name for the column 'region_id'. * @@ -222,6 +229,20 @@ class ColumnKeys extends \TechDivision\Import\Customer\Utils\ColumnKeys */ const ADDRESS_REGION = '_address_region'; + /** + * Name for the column '_address_region_code'. + * + * @var string + */ + const ADDRESS_REGION_CODE = '_address_region_code'; + + /** + * Name for the column '_address_region_id'. + * + * @var string + */ + const ADDRESS_REGION_ID = '_address_region_id'; + /** * Name for the column '_address_street'. * diff --git a/src/Utils/MemberNames.php b/src/Utils/MemberNames.php index ebbab7f..b4d3a05 100644 --- a/src/Utils/MemberNames.php +++ b/src/Utils/MemberNames.php @@ -68,6 +68,13 @@ class MemberNames extends \TechDivision\Import\Customer\Utils\MemberNames */ const REGION = 'region'; + /** + * Name for the member 'region_code'. + * + * @var string + */ + const REGION_CODE = 'region_code'; + /** * Name for the member 'region_id'. * @@ -137,4 +144,11 @@ class MemberNames extends \TechDivision\Import\Customer\Utils\MemberNames * @var string */ const VAT_REQUEST_SUCCESS = 'vat_request_success'; + + /** + * Name for the column 'iso_code'. + * + * @var string + */ + const DIRECTORY_REGION_CODE = 'code'; } diff --git a/src/Utils/RegistryKeys.php b/src/Utils/RegistryKeys.php index ac1e7f4..92fcbd4 100644 --- a/src/Utils/RegistryKeys.php +++ b/src/Utils/RegistryKeys.php @@ -26,6 +26,13 @@ class RegistryKeys extends \TechDivision\Import\Utils\RegistryKeys { + /** + * Key for the registry entry containing the country Regions. + * + * @var string + */ + const COUNTRY_REGIONS = 'countryRegions'; + /** * Key for the registry entry containing the preloaded SKU => entity ID mapping. * diff --git a/src/Utils/SqlStatementKeys.php b/src/Utils/SqlStatementKeys.php index 97f7a9b..c271064 100644 --- a/src/Utils/SqlStatementKeys.php +++ b/src/Utils/SqlStatementKeys.php @@ -222,4 +222,11 @@ class SqlStatementKeys extends \TechDivision\Import\Utils\SqlStatementKeys * @var string */ const CUSTOMER_ADDRESS_INCREMENT_ID = 'select.customer_address.increment_id'; + + /** + * The SQL statement to read all existing fix product tax. + * + * @var string + */ + const SELECT_DIRECTORY_COUNTRY_REGION = 'select.entries.directory_country_region'; } From 1f525bc4a193b96d03250f9cc24a0da5453bfed3 Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Mon, 8 May 2023 10:26:13 +0200 Subject: [PATCH 2/5] use customer subject and pluging --- src/Plugins/GlobalDataPlugin.php | 81 ------------------- .../CustomerAddressRepository.php | 30 ------- .../CustomerAddressRepositoryInterface.php | 7 -- src/Repositories/SqlStatementRepository.php | 5 +- .../CustomerAddressBunchProcessor.php | 8 -- ...CustomerAddressBunchProcessorInterface.php | 7 -- src/Utils/SqlStatementKeys.php | 7 -- 7 files changed, 1 insertion(+), 144 deletions(-) delete mode 100644 src/Plugins/GlobalDataPlugin.php diff --git a/src/Plugins/GlobalDataPlugin.php b/src/Plugins/GlobalDataPlugin.php deleted file mode 100644 index 3e6b7d0..0000000 --- a/src/Plugins/GlobalDataPlugin.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright 2023 TechDivision GmbH - * @license https://opensource.org/licenses/MIT - * @link https://github.com/techdivision/import - * @link http://www.techdivision.com - */ -declare(strict_types=1); - -namespace TechDivision\Import\Customer\Address\Plugins; - -use TechDivision\Import\ApplicationInterface; -use TechDivision\Import\Customer\Address\Services\CustomerAddressBunchProcessorInterface; -use TechDivision\Import\Plugins\AbstractPlugin; -use TechDivision\Import\Customer\Address\Utils\RegistryKeys; - -/** - * Plugin that loads the global data. - * - * @author MET - * @copyright 2023 TechDivision GmbH - * @license https://opensource.org/licenses/MIT - * @link https://github.com/techdivision/import - * @link http://www.techdivision.com - */ -class GlobalDataPlugin extends AbstractPlugin -{ - /** - * @var CustomerAddressBunchProcessorInterface - */ - protected $customerAddressBunchProcessor; - - /** - * @param ApplicationInterface $application - * @param CustomerAddressBunchProcessorInterface $customerAddressBunchProcessor - */ - public function __construct( - ApplicationInterface $application, - CustomerAddressBunchProcessorInterface $customerAddressBunchProcessor - ){ - $this->customerAddressBunchProcessor = $customerAddressBunchProcessor; - parent::__construct($application); - } - - /** - * Process the plugin functionality. - * - * @return void - * @throws \Exception Is thrown, if the plugin can not be processed - */ - public function process() - { - // initialize the array for the global data - $globalData = array(); - - // initialize the global data - $globalData[RegistryKeys::COUNTRY_REGIONS] = $this->getCountryRegions(); - - $globalData = array_merge($this->getImportProcessor()->getGlobalData(), $globalData); - - // add the status with the global data - $this->getRegistryProcessor()->mergeAttributesRecursive( - RegistryKeys::STATUS, - array(RegistryKeys::GLOBAL_DATA => $globalData) - ); - } - - /** - * @return mixed - */ - public function getCountryRegions() - { - return $this->customerAddressBunchProcessor->loadDirectoryCountryRegions(); - } -} diff --git a/src/Repositories/CustomerAddressRepository.php b/src/Repositories/CustomerAddressRepository.php index dbd437b..87233d8 100644 --- a/src/Repositories/CustomerAddressRepository.php +++ b/src/Repositories/CustomerAddressRepository.php @@ -51,11 +51,6 @@ class CustomerAddressRepository extends AbstractRepository implements CustomerAd */ protected $customerAddressIncrementIdStmt; - /** - * @var PDOStatement - */ - protected $directoryCountryRegionsStatement; - /** * Initializes the repository's prepared statements. * @@ -71,8 +66,6 @@ public function init() $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_ADDRESSES)); $this->customerAddressIncrementIdStmt = $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_ADDRESS_INCREMENT_ID)); - $this->directoryCountryRegionsStatement = - $this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::SELECT_DIRECTORY_COUNTRY_REGION)); } /** @@ -121,27 +114,4 @@ public function loadByIncrementIdAndCustomerEntityId($incrementId, $customerId) ); return $this->customerAddressIncrementIdStmt->fetch(\PDO::FETCH_ASSOC); } - /** - * Return's all country regions from directory - * - * @return array - */ - public function findDirectoryCountryRegions() - { - $directoryCountryRegions = []; - - // execute the prepared statement - $this->directoryCountryRegionsStatement->execute(); - - // load the available customer groups - $avalaibleDirectoryCountryRegions = $this->directoryCountryRegionsStatement->fetchAll(); - - // fetch the directory regions and assemble them as array with the codes as key - foreach ($avalaibleDirectoryCountryRegions as $countryRegion) { - $directoryCountryRegions[$countryRegion[MemberNames::DIRECTORY_REGION_CODE]] = $countryRegion; - } - - // return the customer groups - return $directoryCountryRegions; - } } diff --git a/src/Repositories/CustomerAddressRepositoryInterface.php b/src/Repositories/CustomerAddressRepositoryInterface.php index c7f5628..0148eff 100644 --- a/src/Repositories/CustomerAddressRepositoryInterface.php +++ b/src/Repositories/CustomerAddressRepositoryInterface.php @@ -53,11 +53,4 @@ public function load($id); * @return array|null The customer */ public function loadByIncrementIdAndCustomerEntityId($incrementId, $customerId); - - /** - * Return's all country regions from directory - * - * @return array - */ - public function findDirectoryCountryRegions(); } diff --git a/src/Repositories/SqlStatementRepository.php b/src/Repositories/SqlStatementRepository.php index 4e5902a..bff1cf5 100644 --- a/src/Repositories/SqlStatementRepository.php +++ b/src/Repositories/SqlStatementRepository.php @@ -250,10 +250,7 @@ class SqlStatementRepository extends \TechDivision\Import\Repositories\SqlStatem SqlStatementKeys::DELETE_CUSTOMER_ADDRESS_TEXT => 'DELETE FROM ${table:customer_address_entity_text} - WHERE value_id = :value_id', - SqlStatementKeys::SELECT_DIRECTORY_COUNTRY_REGION => - 'SELECT * - FROM ${table:directory_country_region}', + WHERE value_id = :value_id' ); /** diff --git a/src/Services/CustomerAddressBunchProcessor.php b/src/Services/CustomerAddressBunchProcessor.php index c04f9b3..9864918 100755 --- a/src/Services/CustomerAddressBunchProcessor.php +++ b/src/Services/CustomerAddressBunchProcessor.php @@ -592,14 +592,6 @@ public function loadCustomerByEmailAndWebsiteId($email, $websiteId) return $this->getCustomerRepository()->findOneByEmailAndWebsiteId($email, $websiteId); } - /** - * @return mixed - */ - public function loadDirectoryCountryRegions() - { - return $this->getCustomerAddressRepository()->findDirectoryCountryRegions(); - } - /** * Persist's the passed customer address data and return's the ID. * diff --git a/src/Services/CustomerAddressBunchProcessorInterface.php b/src/Services/CustomerAddressBunchProcessorInterface.php index 64c853d..866499e 100644 --- a/src/Services/CustomerAddressBunchProcessorInterface.php +++ b/src/Services/CustomerAddressBunchProcessorInterface.php @@ -142,13 +142,6 @@ public function loadCustomerAddress($id); */ public function loadCustomerByEmailAndWebsiteId($email, $websiteId); - /** - * Return's all country regions from directory - * - * @return array - */ - public function loadDirectoryCountryRegions(); - /** * Persist's the passed customer address data and return's the ID. * diff --git a/src/Utils/SqlStatementKeys.php b/src/Utils/SqlStatementKeys.php index c271064..97f7a9b 100644 --- a/src/Utils/SqlStatementKeys.php +++ b/src/Utils/SqlStatementKeys.php @@ -222,11 +222,4 @@ class SqlStatementKeys extends \TechDivision\Import\Utils\SqlStatementKeys * @var string */ const CUSTOMER_ADDRESS_INCREMENT_ID = 'select.customer_address.increment_id'; - - /** - * The SQL statement to read all existing fix product tax. - * - * @var string - */ - const SELECT_DIRECTORY_COUNTRY_REGION = 'select.entries.directory_country_region'; } From 44f61b638921649b84a912617c611f295affc756 Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Mon, 8 May 2023 12:02:10 +0200 Subject: [PATCH 3/5] fix static test --- src/Subjects/AbstractCustomerAddressSubject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Subjects/AbstractCustomerAddressSubject.php b/src/Subjects/AbstractCustomerAddressSubject.php index d6942a3..041aa18 100644 --- a/src/Subjects/AbstractCustomerAddressSubject.php +++ b/src/Subjects/AbstractCustomerAddressSubject.php @@ -137,7 +137,7 @@ public function getStoreWebsiteIdByCode($code) } /** - * @param string $code + * @param string $code  The code of the region code to return the region ID for * @return integer|null */ public function getCountryRegionIdByCode($code) From 17f63fc0c90a864b9bbfc7bc831c3d46009b6e0c Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Wed, 10 May 2023 13:55:31 +0200 Subject: [PATCH 4/5] Code refactoring --- src/Repositories/SqlStatementRepository.php | 2 +- src/Utils/RegistryKeys.php | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Repositories/SqlStatementRepository.php b/src/Repositories/SqlStatementRepository.php index bff1cf5..3cdf689 100644 --- a/src/Repositories/SqlStatementRepository.php +++ b/src/Repositories/SqlStatementRepository.php @@ -250,7 +250,7 @@ class SqlStatementRepository extends \TechDivision\Import\Repositories\SqlStatem SqlStatementKeys::DELETE_CUSTOMER_ADDRESS_TEXT => 'DELETE FROM ${table:customer_address_entity_text} - WHERE value_id = :value_id' + WHERE value_id = :value_id', ); /** diff --git a/src/Utils/RegistryKeys.php b/src/Utils/RegistryKeys.php index 92fcbd4..1a88ac7 100644 --- a/src/Utils/RegistryKeys.php +++ b/src/Utils/RegistryKeys.php @@ -14,6 +14,8 @@ namespace TechDivision\Import\Customer\Address\Utils; +use TechDivision\Import\Customer\Utils\RegistryKeys as CustomerRegistryKeys; + /** * Utility class containing the unique registry keys. * @@ -23,16 +25,8 @@ * @link https://github.com/techdivision/import-customer-address * @link http://www.techdivision.com */ -class RegistryKeys extends \TechDivision\Import\Utils\RegistryKeys +class RegistryKeys extends CustomerRegistryKeys { - - /** - * Key for the registry entry containing the country Regions. - * - * @var string - */ - const COUNTRY_REGIONS = 'countryRegions'; - /** * Key for the registry entry containing the preloaded SKU => entity ID mapping. * From 841f98854faa0ae08ec41215f79fb1a7404883bf Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Wed, 10 May 2023 15:59:19 +0200 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c8b6de..a58d513 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# Version 17.0.6 + +## Bugfixes + +* none + +## Features + +* Add support for optional region address fields 'region_id' and 'region_code' + # Version 17.0.5 ## Bugfixes