Skip to content

Issue-3139. Visual Swatch not showing on product page when once set as Text Swatch #15316

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

Closed
wants to merge 4 commits into from
Closed

Issue-3139. Visual Swatch not showing on product page when once set as Text Swatch #15316

wants to merge 4 commits into from

Conversation

mmularski
Copy link
Contributor

@mmularski mmularski commented May 18, 2018

  • Fixed issue witch switching visual/text swatch attribute
  • Added default store ID value for visual swatches
  • Updated unit tests

Description

Added default store ID value for visual swatches

Fixed Issues (if relevant)

  1. Visual Swatch not showing on product page when once set as Text Swatch #3139: Visual Swatch not showing on the product page when once set as Text Swatch

Manual testing scenarios

  1. Create configurable product
  2. Create product configurations with newly created attribute (visual swatch)
  3. Change attribute to text swatch
  4. Re-change attribute to visual swatch

Acceptance criteria:
Visual/Text swatches are properly visible on the product page

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)

@dmanners dmanners added the Event: WroCD Contribution day in Wro label May 18, 2018
@mmularski mmularski changed the title Issue-3139 Issue-3139. Visual Swatch not showing on product page when once set as Text Swatch May 18, 2018
) {
$this->swatchCollectionFactory = $collectionFactory;
$this->swatchFactory = $swatchFactory;
$this->swatchHelper = $swatchHelper;
$this->serializer = $serializer ?: ObjectManager::getInstance()->create(Json::class);
$this->storeManager = $storeManager ?: ObjectManager::getInstance()->create(StoreManagerInterface::class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Plugins are not intended to follow Backwards compatibility policy, so the dependency may be added in a regular way. This would also require to fix Json dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/**
* @var StoreManagerInterface
*/
protected $storeManager;
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not encouraged to create more protected properties, as Technical Guidelines suggest to use composition over inheritance. Additionally, Plugins are not supposed to be extended in any way, so property should be private to enforce that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

];
}

foreach ($visualSwatches as $optionId => $storeValues) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any specific reason to introduce another foreach? It looks like logic may be merged in the first one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishakhsuvarov merged with another foreach

$swatchType = $this->determineSwatchType($value);

$this->saveSwatchData($swatch, $optionId, $storeId, $swatchType, $value);
$this->isSwatchExists = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not really good idea for a Plugin to have a state like this.
Definitely not required in the scope of this Pull Request but whole class may be refactored, if you are interested in this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishakhsuvarov Unfortunately, I cannot find extra time for whole class refactoring for now. I agree with you this state is not a good idea, but if I remove it, it could affect other logic in this class. Is it ok to leave this until whole class will be refactored?

@ishakhsuvarov
Copy link
Contributor

Hi @mmularski
Could you please take a look at the comments and introduce some minor fixes?

Also, in case you are interested, this class looks like it would need a complete refactoring, so that might be done as well, optionally.

@mmularski
Copy link
Contributor Author

Hi @ishakhsuvarov
I've committed some changes regarding your review. Could you check them? :)

@ishakhsuvarov
Copy link
Contributor

@mmularski Thanks for the update. I'll run tests on internal CICD and let you know if anything else is needed.

@mmularski
Copy link
Contributor Author

Hi,
any update here?

@ishakhsuvarov
Copy link
Contributor

Hi @mmularski
Our QA has trouble reproducing the issue on 2.2-develop in the first place. Do you have any specific steps you have executed apart the ones described in the ticket and PR?

@ishakhsuvarov
Copy link
Contributor

@magento-engcom-team give me 2.2-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @ishakhsuvarov. Thank you for your request. I'm working on Magento 2.2-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @ishakhsuvarov, here is your Magento instance.
Admin access: https://i-15316-2-2-develop.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@mmularski
Copy link
Contributor Author

@ishakhsuvarov I've reproduced this issue on clear 2.2-develop Magento instance with this 4 steps:
1.Create configurable product
2.Create product configurations with newly created attribute (visual swatch)
3.Change attribute to text swatch
4.Re-change attribute to visual swatch

@mmularski
Copy link
Contributor Author

mmularski commented Aug 16, 2018

Hi, any news here?

@sidolov
Copy link
Contributor

sidolov commented Oct 10, 2018

Hi @mmularski , we still cannot reproduce this issue

Manual testing scenario:

  1. Create configurable product
  2. Create product configurations with newly created attribute (visual swatch)
  3. Change attribute to text swatch
  4. Re-change attribute to visual swatch
  5. Navigate to Product Page

puop8-2f5wr

@sidolov
Copy link
Contributor

sidolov commented Oct 24, 2018

Hi @mmularski , I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@sidolov sidolov closed this Oct 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants