Skip to content
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

Backward compatibility provided by #19765 #22761

Closed
Nazar65 opened this issue May 7, 2019 · 7 comments
Closed

Backward compatibility provided by #19765 #22761

Nazar65 opened this issue May 7, 2019 · 7 comments
Labels
Component: Framework/Code help wanted Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@Nazar65
Copy link
Member

Nazar65 commented May 7, 2019

Summary (*)

#19765
#19761 (comment)
Current fixes still don't provide complete backward compatibility with code designed for Magento 2.0.X, 2.1.X, 2.2.X.
IMO it is not good at all to have any variables related to SKU in abstract entity code. In the best case new class must be implemented and extended from abstract entity.
In case it is impossible to achieve that, then it would be probably better to introduce one more variable to the constructor. It could be something like

Examples (*)

Current fix
$this->_processedEntitiesCount = (count($skuSet)) ? : $this->_processedRowsCount;
can also break custom import. At least it breaks my import, which was written basing on Magento\CatalogImportExport\Model\Import\Product where $this->_processedEntitiesCount is calculated within validateRow() method. validateRow() is triggered from _saveValidatedBunches(), which means that
$this->_processedEntitiesCount = (count($skuSet)) ? : $this->_processedRowsCount;
would override everything after all validateRow(). Similar as it is in M 2.3 for Magento\CatalogImportExport\Model\Import\Product. The only difference that 'sku' is present in CSV for product import and
$this->_processedEntitiesCount = (count($skuSet)) ? : $this->_processedRowsCount;
is valid in this case. But for custom imports written earlier $this->_processedEntitiesCount had to be calculated in the custom import model extended from Magento\ImportExport\Model\Import\Entity\AbstractEntity .

Proposed solution

//...
ProcessingErrorAggregatorInterface $errorAggregator,
$uniqueField = null
) {
        $this->jsonHelper = $jsonHelper;
        $this->_importExportData = $importExportData;
        $this->_resourceHelper = $resourceHelper;
        $this->string = $string;
        $this->errorAggregator = $errorAggregator;

        foreach ($this->errorMessageTemplates as $errorCode => $message) {
            $this->getErrorAggregator()->addErrorMessageTemplate($errorCode, $message);
        }

        $entityType = $config->getEntityType($this->getEntityTypeCode());

        $this->_entityTypeId = $entityType->getEntityTypeId();
        $this->_dataSourceModel = $importData;
        $this->_connection = $resource->getConnection();
        $this->uniqueField = $uniqueField;

Then 'sku' could be injected for all core import classes via di.xml.

In _saveValidatedBunches() we could rename $skuSet into $uniqueFieldSet.

        $bunchSize = $this->_importExportData->getBunchSize();
        $uniqueFieldSet = [];
//...
                try {
                    $rowData = $source->current();
                    if ($this->uniqueField !== null) {
                        $uniqueFieldSet[$rowData[$this->uniqueField]] = true;
                    }
                } catch (\InvalidArgumentException $e) {
                    $this->addRowError($e->getMessage(), $this->_processedRowsCount);
                    $this->_processedRowsCount++;
                    $source->next();
                    continue;
                }
//...
if ($this->uniqueField !== null) {
    $this->_processedEntitiesCount = count($uniqueFieldSet);
}

In case it is impossible to go with null as default value for $uniqueField, then we could set 'sku' there,

//...
ProcessingErrorAggregatorInterface $errorAggregator,
$uniqueField = 'sku'
) {

but then in custom code all developers would have to override that 'uniqueField' in di.xml to make custom import code operational again.

@m2-assistant
Copy link

m2-assistant bot commented May 7, 2019

Hi @Nazar65. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@Nazar65 do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label May 7, 2019
@ghost ghost removed the good first issue label May 7, 2019
@ghost
Copy link

ghost commented May 7, 2019

Thank you @Nazar65 for proposing this as Good First Issue!
Community Maintainers team will review it and add to list.

@Nazar65 Nazar65 self-assigned this May 7, 2019
@m2-assistant
Copy link

m2-assistant bot commented May 7, 2019

Hi @Nazar65. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.
    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

@m2-assistant
Copy link

m2-assistant bot commented Jun 25, 2019

Hi @Nazar65. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@Nazar65 Nazar65 added the Progress: PR Created Indicates that Pull Request has been created to fix issue label Jun 25, 2019
@ghost ghost unassigned Nazar65 Aug 29, 2019
@engcom-Charlie engcom-Charlie self-assigned this Aug 30, 2019
@m2-assistant
Copy link

m2-assistant bot commented Aug 30, 2019

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Charlie engcom-Charlie added Component: Framework/Code Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Aug 30, 2019
@ghost ghost unassigned engcom-Charlie Aug 30, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-19757 were created

Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Aug 30, 2019
@m2-community-project m2-community-project bot removed the Progress: PR Created Indicates that Pull Request has been created to fix issue label Sep 24, 2020
@ghost ghost removed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 20, 2020
@sdzhepa sdzhepa added Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it and removed Progress: ready for dev labels Oct 29, 2020
@gabrieldagama
Copy link
Contributor

The change was done more than a year ago and introducing other changes now may cause other backwards-incompatible changes.

@m2-community-project m2-community-project bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Framework/Code help wanted Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

No branches or pull requests

5 participants