Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

MAGETWO-49985: product custom options export in reverse order fixed #95

Conversation

umarch06
Copy link
Contributor

@umarch06 umarch06 commented Jan 8, 2018

Description

Changed the sort order from descending to ascending while getting custom options for a product, currently default sort order (descending) was used while generating rows for custom options for a product, so now after importing custom options will be displayed in the same order as in which these were exported.

Manual testing scenarios

  1. Create a simple product with two options, the 1st option is a dropdown and the 2nd option is a field, Save it.
  2. System -> Export
  3. System -> Import same file in same store or other
  4. After import, in UI, product options will be in the same order as in it was exported.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@umarch06 umarch06 self-assigned this Jan 8, 2018
@dmanners dmanners self-requested a review January 9, 2018 08:01
@dmanners dmanners self-assigned this Jan 10, 2018
@dmanners dmanners added this to the January 2018 milestone Jan 10, 2018
@@ -1315,8 +1315,7 @@ protected function getCustomOptionsData($productIds)
}
$options = $this->_optionColFactory->create();
/* @var \Magento\Catalog\Model\ResourceModel\Product\Option\Collection $options*/
$options->addOrder('sort_order');
$options->reset()->addOrder('sort_order')->addTitleToResult(
$options->reset()->addOrder('sort_order', 'ASC')->addTitleToResult(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the technical guidelines method chaining should be avoided (http://devdocs.magento.com/guides/v2.2/coding-standards/technical-guidelines.html#2-class-design in 2.15). Would you be able to update this part of the code base to not use chaining. Something like

$options->reset();
$options->addOrder('sort_order', 'ASC');
$options->addTitleToResult($storeId);
$options->addPriceToResult($storeId);
$options->addProductToFilter($productIds);
$options->addValuesToResult($storeId);

This should have the same results but avoids the method chaining.

Of course please also check that this still works as expected after your changes.

@magento-team magento-team merged commit 558f714 into magento-engcom:2.3-develop Jan 10, 2018
magento-team pushed a commit that referenced this pull request Jan 10, 2018
@umarch06 umarch06 deleted the 71-reverse-export-custom-options-fix branch January 18, 2018 09:28
magento-engcom-team pushed a commit that referenced this pull request Apr 13, 2018
MAGETWO-89321: Misconfigured composer.json and composer.lock
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants