From c4ea23c849bc0a78c62ec4bac3f39d3574cf50ac Mon Sep 17 00:00:00 2001 From: lakshmana49 Date: Fri, 8 Dec 2023 18:19:18 +0530 Subject: [PATCH 01/11] ACP2E-2622: Unable to save changes to phone number in existing order details --- .../Model/ResourceModel/Db/VersionControl/Snapshot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php index 0040afa82989..231abe6008d5 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php @@ -67,7 +67,7 @@ public function isModified(\Magento\Framework\DataObject $entity) return true; } foreach ($this->snapshotData[$entityClass][$entity->getId()] as $field => $value) { - if ($entity->getDataByKey($field) != $value) { + if ($entity->getDataByKey($field) !== $value) { return true; } } From 333b3fd6ed7797a3f17eb9968d21857c1120bcd0 Mon Sep 17 00:00:00 2001 From: pradeep1819 Date: Thu, 14 Dec 2023 13:53:43 +0530 Subject: [PATCH 02/11] ACP2E-2653: Disabling Layered Navetion - Does not remove aggregation from Graphql --- .../Category/IncludeDirectChildrenOnly.php | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Aggregations/Category/IncludeDirectChildrenOnly.php b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Aggregations/Category/IncludeDirectChildrenOnly.php index 5fc50452bb70..87b48e171e49 100644 --- a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Aggregations/Category/IncludeDirectChildrenOnly.php +++ b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Aggregations/Category/IncludeDirectChildrenOnly.php @@ -8,7 +8,9 @@ namespace Magento\CatalogGraphQl\DataProvider\Product\LayeredNavigation\Builder\Aggregations\Category; use Magento\Catalog\Api\CategoryListInterface; +use Magento\Catalog\Model\Config\LayerCategoryConfig; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\App\ObjectManager; use Magento\Framework\ObjectManager\ResetAfterRequestInterface; use Magento\Framework\Search\Response\Aggregation; use Magento\Framework\Search\Response\AggregationFactory; @@ -61,25 +63,34 @@ class IncludeDirectChildrenOnly implements ResetAfterRequestInterface */ private $searchCriteriaBuilder; + /** + * @var LayerCategoryConfig|null + */ + private $layerCategoryConfig; + /** * @param AggregationFactory $aggregationFactory * @param BucketFactory $bucketFactory * @param StoreManagerInterface $storeManager * @param CategoryListInterface $categoryList * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param LayerCategoryConfig|null $layerCategoryConfig */ public function __construct( AggregationFactory $aggregationFactory, BucketFactory $bucketFactory, StoreManagerInterface $storeManager, CategoryListInterface $categoryList, - SearchCriteriaBuilder $searchCriteriaBuilder + SearchCriteriaBuilder $searchCriteriaBuilder, + ?LayerCategoryConfig $layerCategoryConfig = null ) { $this->aggregationFactory = $aggregationFactory; $this->bucketFactory = $bucketFactory; $this->storeManager = $storeManager; $this->categoryList = $categoryList; $this->searchCriteriaBuilder = $searchCriteriaBuilder; + $this->layerCategoryConfig = $layerCategoryConfig ?? ObjectManager::getInstance() + ->get(LayerCategoryConfig::class); } /** @@ -91,28 +102,34 @@ public function __construct( */ public function filter(AggregationInterface $aggregation, ?int $storeId): Aggregation { - $categoryIdsRequested = $this->filter['category'] ?? null; - if ($categoryIdsRequested === null) { - return $aggregation; - } - $buckets = $aggregation->getBuckets(); - $categoryBucket = $buckets[self::CATEGORY_BUCKET] ?? null; - if ($categoryBucket === null || empty($categoryBucket->getValues())) { - return $aggregation; + if (!$this->layerCategoryConfig->isCategoryFilterVisibleInLayerNavigation()) { + $buckets = $aggregation->getBuckets(); + unset($buckets[self::CATEGORY_BUCKET]); + } else { + $categoryIdsRequested = $this->filter['category'] ?? null; + if ($categoryIdsRequested === null) { + return $aggregation; + } + $buckets = $aggregation->getBuckets(); + $categoryBucket = $buckets[self::CATEGORY_BUCKET] ?? null; + if ($categoryBucket === null || empty($categoryBucket->getValues())) { + return $aggregation; + } + $categoryIdsRequested = is_array($categoryIdsRequested) ? $categoryIdsRequested : [$categoryIdsRequested]; + $bucketValuesFiltered = $this->filterBucketValues( + $categoryBucket->getValues(), + $categoryIdsRequested, + $storeId + ); + $categoryBucketResolved = $this->bucketFactory->create( + [ + 'name' => self::CATEGORY_BUCKET, + 'values' => $bucketValuesFiltered + ] + ); + $buckets[self::CATEGORY_BUCKET] = $categoryBucketResolved; } - $categoryIdsRequested = is_array($categoryIdsRequested) ? $categoryIdsRequested : [$categoryIdsRequested]; - $bucketValuesFiltered = $this->filterBucketValues( - $categoryBucket->getValues(), - $categoryIdsRequested, - $storeId - ); - $categoryBucketResolved = $this->bucketFactory->create( - [ - 'name' => self::CATEGORY_BUCKET, - 'values' => $bucketValuesFiltered - ] - ); - $buckets[self::CATEGORY_BUCKET] = $categoryBucketResolved; + return $this->aggregationFactory->create([self::BUCKETS_NAME => $buckets]); } From f0da52c2f98cfad9953ad0e02638e5acc1b03128 Mon Sep 17 00:00:00 2001 From: pradeep1819 Date: Wed, 20 Dec 2023 18:20:21 +0530 Subject: [PATCH 03/11] ACP2E-2653: Disabling Layered Navetion - Does not remove aggregation from Graphql --- .../ProductSearchCategoryAggregationsTest.php | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php index 86044c94bb87..b8b71cd91635 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php @@ -225,6 +225,92 @@ private function getGraphQlQuery(string $categoryList, string $includeDirectChil } } } +QUERY; + } + + /** + * Test the categories that appear in aggregation Layered Navigation > Display Category Filter => Yes (default). + * + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + * @throws \Exception + */ + public function testFetchCategoriesWhenDisplayCategoryEnabled(): void + { + $result = $this->aggregationWithDisplayCategorySetting(); + $aggregationAttributeCode = []; + foreach ($result['products']['aggregations'] as $aggregation) { + $this->assertArrayHasKey('attribute_code', $aggregation); + $aggregationAttributeCode[] = $aggregation['attribute_code']; + } + $this->assertTrue(in_array('category_uid', $aggregationAttributeCode)); + } + + /** + * Test the categories not in aggregation when Layered Navigation > Display Category Filter => No. + * + * @magentoConfigFixture catalog/layered_navigation/display_category 0 + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + * @throws \Exception + */ + public function testDontFetchCategoriesWhenDisplayCategoryDisabled(): void + { + $result = $this->aggregationWithDisplayCategorySetting(); + $aggregationAttributeCode = []; + foreach ($result['products']['aggregations'] as $aggregation) { + $this->assertArrayHasKey('attribute_code', $aggregation); + $aggregationAttributeCode[] = $aggregation['attribute_code']; + } + $this->assertFalse(in_array('category_uid', $aggregationAttributeCode)); + } + + /** + * @return array + * @throws \Exception + */ + private function aggregationWithDisplayCategorySetting(): array + { + $query = $this->getGraphQlQueryProductSearch(); + $result = $this->graphQlQuery($query); + + $this->assertArrayNotHasKey('errors', $result); + $this->assertArrayHasKey('aggregations', $result['products']); + return $result; + } + + /** + * Get graphQl query. + * + * @return string + */ + private function getGraphQlQueryProductSearch(): string + { + return << Date: Thu, 21 Dec 2023 11:11:42 +0530 Subject: [PATCH 04/11] ACP2E-2653: Disabling Layered Navetion - Does not remove aggregation from Graphql --- .../GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php index b8b71cd91635..c4fadcf8136e 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchCategoryAggregationsTest.php @@ -267,7 +267,7 @@ public function testDontFetchCategoriesWhenDisplayCategoryDisabled(): void * @return array * @throws \Exception */ - private function aggregationWithDisplayCategorySetting(): array + private function aggregationWithDisplayCategorySetting(): array { $query = $this->getGraphQlQueryProductSearch(); $result = $this->graphQlQuery($query); From c6e5084d4933e5efc83a8edc3470f610536e5b54 Mon Sep 17 00:00:00 2001 From: lakshmana49 Date: Wed, 17 Jan 2024 15:06:35 +0530 Subject: [PATCH 05/11] ACP2E-2622: Unable to save changes to phone number in existing order details --- .../ResourceModel/Db/VersionControl/Snapshot.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php index 231abe6008d5..769ff8597f8e 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php @@ -67,8 +67,15 @@ public function isModified(\Magento\Framework\DataObject $entity) return true; } foreach ($this->snapshotData[$entityClass][$entity->getId()] as $field => $value) { - if ($entity->getDataByKey($field) !== $value) { - return true; + $fieldValue = $entity->getDataByKey($field); + if(is_numeric($fieldValue) && is_numeric($value)) { + if ($fieldValue !== $value) { + return true; + } + } else { + if ($fieldValue != $value) { + return true; + } } } From 314eaeac7b00c28599190174b89c7cf50dfb6080 Mon Sep 17 00:00:00 2001 From: lakshmana49 Date: Wed, 17 Jan 2024 20:51:01 +0530 Subject: [PATCH 06/11] ACP2E-2622: Unable to save changes to phone number in existing order details --- .../Model/ResourceModel/Db/VersionControl/Snapshot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php index 769ff8597f8e..21e34ffa980e 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php @@ -68,7 +68,7 @@ public function isModified(\Magento\Framework\DataObject $entity) } foreach ($this->snapshotData[$entityClass][$entity->getId()] as $field => $value) { $fieldValue = $entity->getDataByKey($field); - if(is_numeric($fieldValue) && is_numeric($value)) { + if (is_numeric($fieldValue) && is_numeric($value)) { if ($fieldValue !== $value) { return true; } From b527f4cd65828092b07bd2eef7f26aa77868f623 Mon Sep 17 00:00:00 2001 From: lakshmana49 Date: Tue, 23 Jan 2024 03:57:44 +0530 Subject: [PATCH 07/11] ACP2E-2622: Unable to save changes to phone number in existing order details --- .../Model/ResourceModel/Order/Address.php | 23 +++++++++++++++++++ .../Db/VersionControl/Snapshot.php | 23 +++++++++++-------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php index c55f73431167..a35a7499396c 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php @@ -122,4 +122,27 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) } return $this; } + + /** + * Check is current order address entity has changes, by comparing current object state with stored snapshot + * + * @param \Magento\Framework\DataObject $entity + * @return bool + */ + protected function isModified(\Magento\Framework\Model\AbstractModel $entity) + { + if (!$entity->getId()) { + return true; + } + $snapChatData = $this->entitySnapshot->getSnapshotData($entity); + foreach ($snapChatData as $field => $value) { + $fieldValue = $entity->getDataByKey($field); + if (is_numeric($fieldValue) && is_numeric($value)) { + if ($fieldValue !== $value) { + return true; + } + } + } + return parent::isModified($entity); + } } diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php index 21e34ffa980e..3e99abe41032 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php @@ -5,6 +5,7 @@ */ namespace Magento\Framework\Model\ResourceModel\Db\VersionControl; +use Magento\Framework\DataObject; use Magento\Framework\ObjectManager\ResetAfterRequestInterface; /** @@ -50,6 +51,17 @@ public function registerSnapshot(\Magento\Framework\DataObject $entity) $this->snapshotData[get_class($entity)][$entity->getId()] = $data; } + /** + * Get snapshot data + * + * @param DataObject $entity + * @return array + */ + public function getSnapshotData(\Magento\Framework\DataObject $entity) + { + return $this->snapshotData[get_class($entity)][$entity->getId()]; + } + /** * Check is current entity has changes, by comparing current object state with stored snapshot * @@ -67,15 +79,8 @@ public function isModified(\Magento\Framework\DataObject $entity) return true; } foreach ($this->snapshotData[$entityClass][$entity->getId()] as $field => $value) { - $fieldValue = $entity->getDataByKey($field); - if (is_numeric($fieldValue) && is_numeric($value)) { - if ($fieldValue !== $value) { - return true; - } - } else { - if ($fieldValue != $value) { - return true; - } + if ($entity->getDataByKey($field) != $value) { + return true; } } From 5ca8bb413e173e8362a4ca7609ddd12cf8e7c452 Mon Sep 17 00:00:00 2001 From: lakshmana49 Date: Tue, 23 Jan 2024 06:38:43 +0530 Subject: [PATCH 08/11] ACP2E-2622: Unable to save changes to phone number in existing order details - Fixed build failures --- .../Magento/Sales/Model/ResourceModel/Order/Address.php | 6 +++--- .../Test/Unit/Model/ResourceModel/Order/AddressTest.php | 8 -------- .../Model/ResourceModel/Db/VersionControl/Snapshot.php | 9 ++++++++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php index a35a7499396c..86809a2bd7f1 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php @@ -15,7 +15,7 @@ class Address extends SalesResource implements OrderAddressResourceInterface { /** - * Event prefix + * Sales order address event prefix * * @var string */ @@ -33,10 +33,10 @@ class Address extends SalesResource implements OrderAddressResourceInterface /** * @param \Magento\Framework\Model\ResourceModel\Db\Context $context - * @param \Magento\Sales\Model\ResourceModel\Attribute $attribute - * @param \Magento\SalesSequence\Model\Manager $sequenceManager * @param Snapshot $entitySnapshot * @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite $entityRelationComposite + * @param \Magento\Sales\Model\ResourceModel\Attribute $attribute + * @param \Magento\SalesSequence\Model\Manager $sequenceManager * @param \Magento\Sales\Model\Order\Address\Validator $validator * @param \Magento\Sales\Model\ResourceModel\GridPool $gridPool * @param string $connectionName diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/AddressTest.php index 9f5fd0e9d1ba..daa1aa60ec52 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/AddressTest.php @@ -98,10 +98,6 @@ public function testSave() ->method('validate') ->with($this->addressMock) ->willReturn([]); - $this->entitySnapshotMock->expects($this->once()) - ->method('isModified') - ->with($this->addressMock) - ->willReturn(true); $this->addressMock->expects($this->once()) ->method('getParentId') ->willReturn(1); @@ -116,10 +112,6 @@ public function testSaveValidationFailed() { $this->expectException('Magento\Framework\Exception\LocalizedException'); $this->expectExceptionMessage('We can\'t save the address:'); - $this->entitySnapshotMock->expects($this->once()) - ->method('isModified') - ->with($this->addressMock) - ->willReturn(true); $this->addressMock->expects($this->any()) ->method('hasDataChanges') ->willReturn(true); diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php index 3e99abe41032..3afeb0535eb1 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php @@ -59,7 +59,14 @@ public function registerSnapshot(\Magento\Framework\DataObject $entity) */ public function getSnapshotData(\Magento\Framework\DataObject $entity) { - return $this->snapshotData[get_class($entity)][$entity->getId()]; + $entityClass = get_class($entity); + $entityId = $entity->getId(); + + if (isset($this->snapshotData[$entityClass][$entityId])) { + return $this->snapshotData[$entityClass][$entityId]; + } + + return []; } /** From 1cecf51694e4cd7d66380fd8c0065a3f99f2970a Mon Sep 17 00:00:00 2001 From: lakshmana49 Date: Wed, 24 Jan 2024 14:49:23 +0530 Subject: [PATCH 09/11] ACP2E-2622: Unable to save changes to phone number in existing order details - Test coverage added --- .../Model/ResourceModel/Order/AddressTest.php | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/AddressTest.php diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/AddressTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/AddressTest.php new file mode 100644 index 000000000000..40c7cd524347 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/AddressTest.php @@ -0,0 +1,111 @@ +objectManager = Bootstrap::getObjectManager(); + $this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage(); + $this->orderAddressRepository = $this->objectManager->get(OrderAddressRepositoryInterface::class); + $this->orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); + } + + /** + * Check to see if leading zeros have been added to the number strings + * in the order address's phone field. + * + * @return void + * @throws LocalizedException + */ + #[ + DbIsolation(false), + DataFixture(ProductFixture::class, as: 'product'), + DataFixture(Customer::class, as: 'customer'), + DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'quote'), + DataFixture(AddProductToCart::class, ['cart_id' => '$quote.id$', 'product_id' => '$product.id$', 'qty' => 1]), + DataFixture(SetBillingAddress::class, [ + 'cart_id' => '$quote.id$', + 'address' => [ + 'customer_id' => '$customer.id$', + 'telephone' => '009999999999' + ] + ]), + DataFixture(SetShippingAddress::class, ['cart_id' => '$quote.id$']), + DataFixture(SetDeliveryMethodFixture::class, ['cart_id' => '$quote.id$']), + DataFixture(SetPaymentMethodFixture::class, ['cart_id' => '$quote.id$']), + DataFixture(PlaceOrderFixture::class, ['cart_id' => '$quote.id$'], 'order') + ] + public function testOrderAddressUpdateWithTelephone(): void + { + $telephoneValue = '9999999999'; + $order = $this->fixtures->get('order'); + $address = $this->orderAddressRepository->get($order->getBillingAddressId()); + $address->setTelephone($telephoneValue); + $this->orderAddressRepository->save($address); + $updatedOrder = $this->orderRepository->get($order->getId()); + $billingAddress = $updatedOrder->getBillingAddress(); + $updatedTelephoneValue = $billingAddress->getTelephone(); + $this->assertEquals($telephoneValue, $updatedTelephoneValue); + } +} From 4c0e7339f93c4049391203124cb1779412bc0a66 Mon Sep 17 00:00:00 2001 From: lakshmana49 Date: Mon, 29 Jan 2024 14:25:24 +0530 Subject: [PATCH 10/11] ACP2E-2622: Unable to save changes to phone number in existing order details - Fixed CR comments --- .../Magento/Sales/Model/ResourceModel/Order/Address.php | 8 +++----- .../Sales/Model/ResourceModel/Order/AddressTest.php | 1 - .../Model/ResourceModel/Db/VersionControl/Snapshot.php | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php index 86809a2bd7f1..e2cb479355a6 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php @@ -5,6 +5,7 @@ */ namespace Magento\Sales\Model\ResourceModel\Order; +use Magento\Framework\Model\AbstractModel; use Magento\Sales\Model\ResourceModel\EntityAbstract as SalesResource; use Magento\Sales\Model\Spi\OrderAddressResourceInterface; use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot; @@ -124,12 +125,9 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) } /** - * Check is current order address entity has changes, by comparing current object state with stored snapshot - * - * @param \Magento\Framework\DataObject $entity - * @return bool + * @inheritdoc */ - protected function isModified(\Magento\Framework\Model\AbstractModel $entity) + protected function isModified(AbstractModel $entity): bool { if (!$entity->getId()) { return true; diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/AddressTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/AddressTest.php index 40c7cd524347..c0156062495d 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/Order/AddressTest.php @@ -79,7 +79,6 @@ protected function setUp(): void * @throws LocalizedException */ #[ - DbIsolation(false), DataFixture(ProductFixture::class, as: 'product'), DataFixture(Customer::class, as: 'customer'), DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'quote'), diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php index 3afeb0535eb1..988fa8ce5bf4 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php @@ -57,7 +57,7 @@ public function registerSnapshot(\Magento\Framework\DataObject $entity) * @param DataObject $entity * @return array */ - public function getSnapshotData(\Magento\Framework\DataObject $entity) + public function getSnapshotData(DataObject $entity): array { $entityClass = get_class($entity); $entityId = $entity->getId(); From ad2d93ef6ebec09be4a80b94476cb9768ddf5a89 Mon Sep 17 00:00:00 2001 From: lakshmana49 Date: Tue, 13 Feb 2024 18:50:35 +0530 Subject: [PATCH 11/11] ACP2E-2622: Unable to save changes to phone number in existing order details - Fixed CR comments --- app/code/Magento/Sales/Model/ResourceModel/Order/Address.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php index e2cb479355a6..40967acb3ea4 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Address.php @@ -132,8 +132,8 @@ protected function isModified(AbstractModel $entity): bool if (!$entity->getId()) { return true; } - $snapChatData = $this->entitySnapshot->getSnapshotData($entity); - foreach ($snapChatData as $field => $value) { + $snapShotData = $this->entitySnapshot->getSnapshotData($entity); + foreach ($snapShotData as $field => $value) { $fieldValue = $entity->getDataByKey($field); if (is_numeric($fieldValue) && is_numeric($value)) { if ($fieldValue !== $value) {