Skip to content

Image Swatch size change not working #12647

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
ghost opened this issue Dec 12, 2017 · 3 comments
Closed

Image Swatch size change not working #12647

ghost opened this issue Dec 12, 2017 · 3 comments
Assignees
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line 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 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 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release

Comments

@ghost
Copy link

ghost commented Dec 12, 2017

Preconditions

  1. Magento Commerce 2.1.8
  2. Have an active frontend theme whose first letter comes alphabetically before "Magento/blank" e.g. "Acme/default"
  3. Have an "Visual swatch" attribute with at least one option
  4. Have a configurable product that offers this "Visual swatch" as an option with one simple product using it.

Steps to reproduce

  1. In "app/design/frontend/YOUR THEME/etc/view.xml" add changes for the image swatches. (e.g. "YOUR THEME" may be "Acme/default")
<?xml version="1.0"?>
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
    <media>
        <images module="Magento_Catalog">
            <image id="swatch_image" type="swatch_image">
                <width>250</width>
                <height>250</height>
            </image>
            <image id="swatch_thumb" type="swatch_thumb">
                <width>500</width>
                <height>500</height>
            </image>
            <image id="swatch_image_base" type="swatch_image">
                <width>250</width>
                <height>250</height>
            </image>
            <image id="swatch_thumb_base" type="swatch_thumb">
                <width>500</width>
                <height>500</height>
            </image>
        </images>
    </media>
</view>
  1. Flush Magento Cache
  2. In backend go to Stores => (Attributes) Product and edit your "Visual swatch" attribute
  3. Upload a new image for the option used in the simple product.
  4. Flush Magento Cache and go to the product detail page of that simple product
  5. Inspect the "Visual swatch" option image with the inspector of your browser

Expected result

The background image used for the visual swatch has the dimensions 250x250

Actual result

The background image used for the visual swatch has the dimensions 30x20 which represents the default setting


Underlying issue

The media helper in the module Magento_Swatches loops through all, even unused, themes in an alphabetical order to apply their view configuration.
In our case loading the view configuration happened in the following order:

  1. Acme/default (swatch_image: 250x250, swatch_thumb: 500x500)
  2. Magento/blank (swatch_image: 30x20, swatch_thumb: 110x90)
  3. Magento/luma (swatch_image: 30x20, swatch_thumb: 110x90)

Each step overwrites its previous settings therefore we don't see the dimensions of the swatch image changing.

Uploading image for a visual swatch option happens here:
Magento/Swatches/Controller/Adminhtml/Iframe/Show.php#L105

// ...
$this->swatchHelper->generateSwatchVariations($newFile);

generateSwatchVariations
Magento/Swatches/Helper/Media.php#L184

// ...
$imageConfig = $this->getImageConfig();

getImageConfig
Magento/Swatches/Helper/Media.php#L253

public function getImageConfig() {
    // ... 
    foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
    // ...
}

The problem is that the function loadRegisteredThemes returns all themes in an alphabetical order, even unused ones. It should load themes in the order they are used in frontend taking their hierarchy into account and also skip themes that are not used.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 12, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Feb 15, 2018
@magento-engcom-team
Copy link
Contributor

@joachim-havloujian, thank you for your report.
We've acknowledged the issue and added to our backlog.

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Feb 15, 2018
@magento-engcom-team
Copy link
Contributor

Hi @joachim-havloujian. Thank you for your report.
The issue has been fixed in #13506 by @pmclain in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Feb 16, 2018
@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Nov 15, 2018

Hi @TomashKhamlai. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

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

  • 2. 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!

  • 3. 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

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@TomashKhamlai TomashKhamlai self-assigned this Nov 15, 2018
@TomashKhamlai TomashKhamlai removed the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Nov 15, 2018
@magento magento deleted a comment from magento-engcom-team Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line 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 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 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release
Projects
None yet
Development

No branches or pull requests

2 participants