|
7 | 7 |
|
8 | 8 | namespace Magento\CatalogImportExport\Model\Import\ProductTest;
|
9 | 9 |
|
| 10 | +use Magento\Catalog\Helper\Data as CatalogConfig; |
10 | 11 | use Magento\Catalog\Model\Product;
|
11 | 12 | use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
|
| 13 | +use Magento\Catalog\Test\Fixture\Product as ProductFixture; |
12 | 14 | use Magento\CatalogImportExport\Model\Import\ProductTestBase;
|
13 | 15 | use Magento\CatalogInventory\Model\StockRegistry;
|
14 | 16 | use Magento\Framework\Api\SearchCriteria;
|
|
17 | 19 | use Magento\ImportExport\Helper\Data;
|
18 | 20 | use Magento\ImportExport\Model\Import;
|
19 | 21 | use Magento\ImportExport\Model\Import\Source\Csv;
|
| 22 | +use Magento\ImportExport\Test\Fixture\CsvFile as CsvFileFixture; |
| 23 | +use Magento\Store\Model\ScopeInterface; |
| 24 | +use Magento\Store\Model\Store; |
| 25 | +use Magento\TestFramework\Fixture\Config; |
| 26 | +use Magento\TestFramework\Fixture\DataFixture; |
| 27 | +use Magento\TestFramework\Fixture\DataFixtureStorageManager; |
20 | 28 | use Magento\UrlRewrite\Model\ResourceModel\UrlRewriteCollection;
|
21 | 29 |
|
22 | 30 | /**
|
@@ -725,4 +733,33 @@ public function testImportProductWithTaxClassNone(): void
|
725 | 733 | $simpleProduct = $this->getProductBySku('simple2');
|
726 | 734 | $this->assertSame('0', (string) $simpleProduct->getTaxClassId());
|
727 | 735 | }
|
| 736 | + |
| 737 | + #[ |
| 738 | + Config(CatalogConfig::XML_PATH_PRICE_SCOPE, CatalogConfig::PRICE_SCOPE_WEBSITE, ScopeInterface::SCOPE_STORE), |
| 739 | + DataFixture(ProductFixture::class, ['price' => 10], 'product'), |
| 740 | + DataFixture( |
| 741 | + CsvFileFixture::class, |
| 742 | + [ |
| 743 | + 'rows' => [ |
| 744 | + ['sku', 'store_view_code', 'price'], |
| 745 | + ['$product.sku$', 'default', '9'], |
| 746 | + ['$product.sku$', 'default', '8'], |
| 747 | + ] |
| 748 | + ], |
| 749 | + 'file' |
| 750 | + ), |
| 751 | + ] |
| 752 | + public function testImportPriceInStoreViewShouldNotOverrideDefaultScopePrice(): void |
| 753 | + { |
| 754 | + $fixtures = DataFixtureStorageManager::getStorage(); |
| 755 | + $sku = $fixtures->get('product')->getSku(); |
| 756 | + $pathToFile = $fixtures->get('file')->getAbsolutePath(); |
| 757 | + $importModel = $this->createImportModel($pathToFile); |
| 758 | + $this->assertErrorsCount(0, $importModel->validateData()); |
| 759 | + $importModel->importData(); |
| 760 | + $product = $this->productRepository->get($sku, storeId: Store::DEFAULT_STORE_ID, forceReload: true); |
| 761 | + $this->assertEquals(10, $product->getPrice()); |
| 762 | + $product = $this->productRepository->get($sku, storeId: Store::DISTRO_STORE_ID, forceReload: true); |
| 763 | + $this->assertEquals(9, $product->getPrice()); |
| 764 | + } |
728 | 765 | }
|
0 commit comments