@@ -415,6 +415,66 @@ public function testPartialUpdateShouldNotOverrideImagesRolesInheritance(): void
415
415
);
416
416
}
417
417
418
+ /**
419
+ * @magentoApiDataFixture Magento\Catalog\Test\Fixture\Product as:product1
420
+ * @magentoApiDataFixture Magento\Catalog\Test\Fixture\Product as:product2
421
+ */
422
+ public function testPartialUpdateShouldNotOverrideUrlKeyInheritance (): void
423
+ {
424
+ /** @var ProductRepositoryInterface $productRepository */
425
+ $ productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
426
+ $ store = $ this ->objectManager ->get (Store::class);
427
+ $ defaultStore = $ store ->load ('default ' , 'code ' );
428
+ $ sku2 = $ this ->fixtures ->get ('product2 ' )->getSku ();
429
+ $ sku1Name = $ this ->fixtures ->get ('product1 ' )->getName ();
430
+ $ sku2NewName = $ this ->fixtures ->get ('product2 ' )->getName () . ' storeview ' ;
431
+ $ sku2UrlKey = $ this ->fixtures ->get ('product2 ' )->getUrlKey ();
432
+
433
+ // Change the second product name with the first product name in default store view
434
+ $ this ->saveProduct (
435
+ [
436
+ ProductInterface::SKU => $ sku2 ,
437
+ 'name ' => $ sku1Name
438
+ ],
439
+ $ defaultStore ->getCode ()
440
+ );
441
+ $ response = $ this ->flattenCustomAttributes ($ this ->getProduct ($ sku2 , $ defaultStore ->getCode ()));
442
+ $ this ->assertEquals ($ sku1Name , $ response ['name ' ]);
443
+ // Assert that Url Key has not changed
444
+ $ this ->assertEquals ($ sku2UrlKey , $ response ['url_key ' ]);
445
+ $ product = $ productRepository ->get ($ sku2 , false , $ defaultStore ->getId (), true );
446
+ $ this ->assertOverriddenValues (
447
+ [
448
+ 'name ' => true ,
449
+ 'url_key ' => false ,
450
+ ],
451
+ $ product ,
452
+ (int ) $ defaultStore ->getId ()
453
+ );
454
+
455
+ // Change the second product name with a new name in default store view
456
+ $ this ->saveProduct (
457
+ [
458
+ ProductInterface::SKU => $ sku2 ,
459
+ 'name ' => $ sku2NewName
460
+ ],
461
+ $ defaultStore ->getCode ()
462
+ );
463
+ $ response = $ this ->flattenCustomAttributes ($ this ->getProduct ($ sku2 , $ defaultStore ->getCode ()));
464
+ $ this ->assertEquals ($ sku2NewName , $ response ['name ' ]);
465
+ // Assert that Url Key has not changed
466
+ $ this ->assertEquals ($ sku2UrlKey , $ response ['url_key ' ]);
467
+ $ product = $ productRepository ->get ($ sku2 , false , $ defaultStore ->getId (), true );
468
+ $ this ->assertOverriddenValues (
469
+ [
470
+ 'name ' => true ,
471
+ 'url_key ' => false ,
472
+ ],
473
+ $ product ,
474
+ (int ) $ defaultStore ->getId ()
475
+ );
476
+ }
477
+
418
478
/**
419
479
* @param array $expected
420
480
* @param array $actual
0 commit comments