-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Various fixes in Magento 2 core to support MSI #13434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various fixes in Magento 2 core to support MSI #13434
Conversation
'label' => __('Delete'), | ||
'class' => 'delete', | ||
'on_click' => | ||
"deleteConfirm('{$this->confirmationMessage}', '{$url}', {data:{{$this->idFieldName}:{$id}}})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these variables to be escaped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ihor-sviziev escaped confirmationMessage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move to Lib Predefined ID trait which we use in MSI
use Magento\Framework\EntityManager\HydratorInterface; | ||
use Magento\InventoryApi\Api\Data\SourceItemInterface; | ||
use Magento\InventoryApi\Api\SourceItemRepositoryInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependency on MSI in test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maghamed removed.
class IndexNameResolver implements IndexNameResolverInterface | ||
{ | ||
/** | ||
* TODO: move to separate configurable interface (https://github.com/magento-engcom/msi/issues/213) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo should be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider not removing but fixing todo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maghamed removed
} | ||
|
||
/** | ||
* TODO: move to separate configurable interface (https://github.com/magento-engcom/msi/issues/213) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo should be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maghamed removed
private $replicaTableSuffix = '_replica'; | ||
|
||
/** | ||
* TODO: move to separate configurable interface (https://github.com/magento-engcom/msi/issues/213) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo should be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maghamed removed
@@ -21,8 +21,12 @@ | |||
</testsuite> | |||
<testsuite name="Magento Integration Tests"> | |||
<directory suffix="Test.php">testsuite</directory> | |||
<directory suffix="Test.php">../../../app/code/*/*/Test/Integration</directory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove all mentions about MSI from phpunit.xml.dist (the same for WebApi)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naydav but there is no mentioning of MSI in this test configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naydav removed
@@ -74,6 +103,7 @@ public function checkStockItemData($sku, array $expectedData) | |||
$productLoadedByModel = $this->productFactory->create(); | |||
$productLoadedByModel->load($product->getId()); | |||
$this->doCheckStockItemData($product, $expectedData); | |||
$this->checkIntegrityWithInventory($product, $expectedData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove this check
This is related only to MSI project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check fully relies on Legacy CatalogInventory
/**
* @param Product $product
* @param array $expectedData
* @return void
*/
private function checkIntegrityWithInventory(Product $product, array $expectedData)
{
$searchCriteria = $this->searchCriteriaBuilder
->addFilter(SourceItemInterface::SOURCE_CODE, $this->defaultSourceProvider->getCode())
->addFilter(SourceItemInterface::SKU, $product->getSku())
->create();
$sourceItems = $this->sourceItemRepository->getList($searchCriteria)->getItems();
Assert::assertCount(1, $sourceItems);
$sourceItem = reset($sourceItems);
Assert::assertEquals(
$expectedData[StockItemInterface::QTY],
$sourceItem->getQuantity()
);
Assert::assertEquals(
$expectedData[StockItemInterface::IS_IN_STOCK],
(int)$sourceItem->getStatus()
);
}
there are no problems to have it in CE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maghamed $this->sourceItemRepository is instance of Magento\InventoryApi\Api\SourceItemRepositoryInterface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naydav removed
@@ -203,7 +203,8 @@ protected function _applyFixtures(array $fixtures) | |||
*/ | |||
protected function _revertFixtures() | |||
{ | |||
foreach ($this->_appliedFixtures as $fixture) { | |||
$appliedFixtures = array_reverse($this->_appliedFixtures); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to do same for WebApi framework
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naydav done
@@ -0,0 +1 @@ | |||
MultiDimensionalIndexer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to provide more descriptive read me
* | ||
* @api | ||
*/ | ||
interface StockItemImporterInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no default implementation of this interface in CE, just in MSI
that will lead to Fatal Error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@vrann @maghamed @naydav I strongly suggest to try and keep information on original history from the MSI repository, possible cherry-picking related commits, or, at least, giving credits to the original authors in the commit message to this change set. Additionally, provided description is not clear on what was changed in the scope of this PR, making it hard to identify and test components affected by this commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update Pull Request description to describe the affected components and possible impact.
/** | ||
* Constructor | ||
* | ||
* @param \Magento\Backend\App\Action\Context $context | ||
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory | ||
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory | ||
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory | ||
* @param \Magento\ImportExport\Model\Import\SampleFileProvider $sampleFileProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect order of params in docBlock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishakhsuvarov fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In constructor signature SampleFileProvider
is after ComponentRegistrar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -11,6 +11,7 @@ | |||
use Magento\Framework\Setup\InstallSchemaInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InstallSchema
is obsolete. Please update with latest mainline and use declarative schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -19,6 +19,10 @@ | |||
<testsuite name="Magento REST web API functional tests"> | |||
<directory suffix="Test.php">testsuite</directory> | |||
<exclude>testsuite/Magento/GraphQl</exclude> | |||
<directory suffix="Test.php">../../../app/code/*/*/Test/Api</directory> | |||
</testsuite> | |||
<testsuite name="msi"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this was only needed to execute tests on MSI
fork
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishakhsuvarov removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is it removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* @return array | ||
*/ | ||
public static function getWhitelist($fileTypes = ['php'], $changedFilesBaseDir = '', $baseFilesFolder = '') | ||
{ | ||
public static function getWhitelist( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates to this test are not reflected in PR description.
Please update with relevant information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
/** | ||
* Tests whitelisted files for strict type declarations. | ||
*/ | ||
public function testStrictTypes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be implemented consistently with other static tests using PHPCS
@@ -0,0 +1 @@ | |||
# Format: <componentType=module|library|theme|language|*> <componentName> <globPattern> or simply <globPattern> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reflect these changes in PR description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -0,0 +1 @@ | |||
# Format: <componentType=module|library|theme|language|*> <componentName> <globPattern> or simply <globPattern> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it required to have blacklist
and whitelist
at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishakhsuvarov blacklist removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishakhsuvarov, blacklist returned. Yes it is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no value in delivering test which has empty whitelist. I assume it would not test anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blacklist deleted.
dev/travis/before_script.sh
Outdated
@@ -71,7 +71,7 @@ case $TEST_SUITE in | |||
--output-file="$changed_files_ce" \ | |||
--base-path="$TRAVIS_BUILD_DIR" \ | |||
--repo='https://github.com/magento/magento2.git' \ | |||
--branch="$TRAVIS_BRANCH" | |||
--branch='$TRAVIS_BRANCH' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change only seems to bring more inconsistency to this script
* @param string $connectionName | ||
* @return bool | ||
*/ | ||
public function isExist(IndexName $indexName, string $connectionName): bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any obstacle in making create
and delete
idempotent eliminating this method?
…nges-no-history # Conflicts: # app/code/Magento/CatalogImportExport/Model/Import/Product.php # app/code/Magento/Store/Setup/InstallSchema.php # app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js # app/etc/di.xml # composer.lock
…nges-no-history # Conflicts: # app/code/Magento/Store/Setup/Patch/Schema/InitializeStoresAndWebsites.php # app/etc/di.xml
@p-bystritsky Please avoid commit messages like |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getButtonData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class seems to be unused in the current implementation.
I would suggest delivering it with the code which actually uses it and provides functional test coverage or with unit/integration test which would ensure that it is not broken in the future.
private function getModuleName(string $entityName): string | ||
{ | ||
if (!isset($this->samples[$entityName])) { | ||
throw new NoSuchEntityException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use NoSuchEntityException
for missed array key?
Maybe do we need to use something like \Magento\Framework\Exception\InputException
?
*/ | ||
private function getPath(string $entityName): string | ||
{ | ||
$directoryRead = $this->getDirectoryRead($entityName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Underhood of this method, we create the directory, but in getModuleName
(next call) we can throw the exception
So maybe do we need to finish all of the checks before performing some actions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* @param string $connectionName | ||
* @return void | ||
*/ | ||
public function saveIndex(IndexName $indexName, \Traversable $documents, string $connectionName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the purpose of using connectionName as an argument for index handler?
Why this is not a responsibility of index class?
* @param string $connectionName | ||
* @return void | ||
*/ | ||
public function cleanIndex(IndexName $indexName, \Traversable $documents, string $connectionName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that you use indexName with pre-build information about current dimension - it forse us to build it in client code. But we can pass DImensionInterface (specific for concrete index) which will have all required information for build index table name + the same approach can be use for resolve table name on front
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, this approach we use in draft implementation: https://github.com/magento-performance/magento2ce/blob/eac69331ff5208ab28ab5ad10db340c3d9674d8a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Shard/ShardTableNameResolver.php#L20https://github.com/magento-performance/magento2ce/blob/eac69331ff5208ab28ab5ad10db340c3d9674d8a/app/code/Magento/Catalog/Model/Indexer/Product/Price/Shard/ShardTableNameResolver.php#L20
Shard - this is a presentation of specific dimensions (sevaral dimenstion can be used, e.g. for Price Indexer)
|
…nges-no-history # Conflicts: # composer.lock
…o msi-core-changes-no-history
…E_ID into the db_schema_whitelist.json as it should always exists even if we don't have index anymore
…o msi-core-changes-no-history
…nges-no-history # Conflicts: # composer.lock
…nly for added files.
c114abd
to
e949bdb
Compare
Set of changes in the Magento core used by MSI
Description
Manual testing scenarios
Bamboo Tests:
Jenkins:
https://m2build.devops.magento.com/job/Public-Pull-Request/206/ .
Contribution checklist