Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 7, 2025

Description (*)

Configurable attribute options on category/listing pages were displaying in reversed order and with incorrect lowercase labels, inconsistent with product detail pages.

Root causes:

  • SQL query in _getOptionLabels() lacked ORDER BY options.sort_order, resulting in unpredictable ordering
  • Label normalization (for case-insensitive image matching) was applied to display values

Changes:

Collection.php

  • Added ORDER BY options.sort_order ASC to SQL query
  • Leverages PHP array insertion order to maintain sort

Mediafallback.php

  • Split label handling: $optionLabelsOriginal for display, $optionLabels (normalized) for image matching
  • $listSwatchValues now uses original case labels for rendering
  • $mapping continues using normalized labels to preserve case-insensitive image matching

Related Pull Requests

Fixed Issues (if relevant)

Manual testing scenarios (*)

  1. Create a configurable product with dropdown attribute (e.g., Size: S, M, L, XL) in backend with uppercase labels
  2. Set attribute position values (1, 2, 3, 4) and enable "Used in Product Listing"
  3. View product detail page - verify options display as: S, M, L, XL (uppercase, correct order)
  4. View category page - verify options display as: S, M, L, XL (uppercase, correct order, not reversed)
  5. Verify images still match correctly with option labels (case-insensitive matching preserved)

Questions or comments

N/A

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] Configurable attribute options order reversed on category page</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In the latest version, when viewing a configurable product:

On the Product Detail Page, the configurable attribute (e.g., size) options are displayed in the correct order as defined in the backend.

Image

On the Category / Product Listing Page, the same configurable attribute options appear in reversed order.

Image

This behavior can be confusing for users and inconsistent with the product detail display.

Expected Behavior

The configurable attribute options should appear in the same order on the category page as on the product detail page, respecting the order set in the backend.

Steps To Reproduce

  1. Create a configurable product with a dropdown attribute (e.g., size) that has multiple options (S, M, L, XL).
Image
  1. Ensure the attribute is set to be used in product listings.

  2. View the product on the Product Detail Page – the options are in the correct order (S → M → L → XL).

  3. View the product on the Category Page (e.g., using swatches or options) – the options are reversed (XL → L → M → S).

Environment

- OpenMage: latest cloned from the repository, no sample data
- PHP: 8.4
- Theme: RWD (default OpenMage / Magento RWD theme)
- Configurable Swatches enabled
- Attribute used in product listing
- No custom modifications to sorting applied

Anything else?

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

@addison74 Additionally, on the category page the size options are displayed in lowercase letters, instead of using the exact attribute option labels as defined in the backend (which are uppercase).
<ul class="configurable-swatch-list configurable-swatch-size clearfix">
    <li class="option-s not-available" data-product-id="5" data-option-label="s">
        <a href="javascript:void(0)" name="s" class="swatch-link swatch-link-134" title="s" style="height: 17px; min-width: 17px;">
            <span class="swatch-label" style="height: 15px; min-width: 15px; line-height: 15px;">
                s
            </span>
            <span class="x" style="display: block;"></span>
        </a>
    </li>

    <li class="option-m" data-product-id="5" data-option-label="m">
        <a href="javascript:void(0)" name="m" class="swatch-link swatch-link-134" title="m" style="height: 17px; min-width: 17px;">
            <span class="swatch-label" style="height: 15px; min-width: 15px; line-height: 15px;">
                m
            </span>
        </a>
    </li>

    <li class="option-l" data-product-id="5" data-option-label="l">
        <a href="javascript:void(0)" name="l" class="swatch-link swatch-link-134" title="l" style="height: 17px; min-width: 17px;">
            <span class="swatch-label" style="height: 15px; min-width: 15px; line-height: 15px;">
                l
            </span>
        </a>
    </li>

    <li class="option-xl" data-product-id="5" data-option-label="xl">
        <a href="javascript:void(0)" name="xl" class="swatch-link swatch-link-134" title="xl" style="height: 17px; min-width: 17px;">
            <span class="swatch-label" style="height: 15px; min-width: 15px; line-height: 15px;">
                xl
            </span>
        </a>
    </li>
</ul>
```</body></comment_new>
</comments>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@github-actions github-actions bot added the Component: ConfigurableSwatches Relates to Mage_ConfigurableSwatches label Dec 7, 2025
Copilot AI changed the title [WIP] Fix configurable attribute options order on category page Fix configurable attribute option ordering and case on product listing pages Dec 7, 2025
Copilot AI requested a review from addison74 December 7, 2025 20:51
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 7, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

Test Results

962 tests   954 ✅  15s ⏱️
211 suites    8 💤
  1 files      0 ❌

Results for commit a060fa7.

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: ConfigurableSwatches Relates to Mage_ConfigurableSwatches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Configurable attribute options order reversed on category page

2 participants