Amazon’s Washington State Ad Tax: What Sellers Need to Know
Reading Time: 3 minutesAmazon recently announced a significant change for sellers advertising in Washington state:…
In Magento2, referring to the products’ form attributes and their options, get ‘render dynamically,’ means that as an admin you can add as many attributes and as many options to that product attribute as you want. This is handled by using the strategy of data and meta-data. Now the problem is if you create a custom attribute with 100 options then it will be hard for the user to select any particular one if it’s not sorted alphabetically. In this blog, we will explain how can you sort product attributes options alphabetically to make it user-friendly.
We are assuming that you already have an idea to create a custom module in Magento2. In Case you don’t, then no worries you can follow the below-mentioned steps-
Here we are going to use a plugin for extending the functionality of meta-data. But if you have no idea how to create a plugin you may check it on Magento2 dev-docs to get a brief idea about Magento2 plugins.
We assume that you already have a basic idea about Magento2 coding.
Write the below code in your Vendor\Module\etc\adminhtml\di.xml
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav"> <plugin name="after_ui_eav_product_form_modifier" type="Vendor\Module\Plugin\Ui\DataProvider\Product\Form\Modifier\Eav" sortOrder="1" disabled="false"/> </type> </config>
Now create a plugin file with the namespace
Vendor\Module\Plugin\Ui\DataProvider\Product\Form\Modifier\Eav, and add the below code.
<?php namespace Vendor\Module\Plugin\Ui\DataProvider\Product\Form\Modifier; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav; /** * Class Eav */ class Eav { const ATTRIBUTE_TO_SORT = ['xyz_attr1' ,'xyz_attr2']; /** * Initial meta setup * * @param Eav $subject * @param array $result * @return array */ public function afterSetupAttributeMeta(Eav $subject, $result){ if (isset($result['arguments']['data']['config']['code'])) { $code = $result['arguments']['data']['config']['code']; if (in_array($code, self::ATTRIBUTE_TO_SORT)){ if (isset($result['arguments']['data']['config']['options'])) { $options = &$result['arguments']['data']['config']['options']; usort($options, function($a, $b) { return $a['label'] > $b['label']; }); } } } return $result; } }
In this, we are using “usort” for the multi-select attribute options, so this code will sort only the multidimensional array, it will sort the array options by labels.
Reading Time: 3 minutesAmazon recently announced a significant change for sellers advertising in Washington state:…
Reading Time: 14 minutesBlack Friday–Cyber Monday used to be a weekend. Now it’s a pressure…
Reading Time: 2 minutesKey Updates Shopify is deprecating the “Sell from all locations to all…
Reading Time: 2 minutesWhat’s New Amazon has published a Data Processing Addendum (DPA) for Multi-Channel…
Reading Time: 2 minutesKey Highlights AI-driven traffic to U.S. retail sites will increase by 520%…
Reading Time: 3 minutesDid you know, a new one-tap ordering feature from Amazon is set…
Reading Time: 2 minutesWalmart has overtaken eBay to become the No. 2 U.S. retail eCommerce…
Reading Time: 2 minutesA new step in AI-driven commerce offers merchants direct access to hundreds…
Reading Time: 2 minutesAmazon has officially launched Amazon Haul in Spain, a budget-focused storefront designed…
Reading Time: 2 minutesOpenAI is bringing ecommerce transactions directly into ChatGPT with the debut of…
Reading Time: 2 minutesAmazon has introduced a new FBA multi-unit discount for Amazon Business orders,…
Reading Time: 2 minutesNews Summary At its recent Etsy Up event (September 2025), Etsy unveiled…
Reading Time: 2 minutesNews Summary eBay has rolled out an update that now defaults all…
Reading Time: 2 minuteseBay has announced its acquisition of Tise, a Nordic consumer-to-consumer (C2C) social…
Reading Time: 3 minutesWalmart’s seasonal practices and incentives around holiday shipping have evolved, impacting seller…
Reading Time: 2 minutesAmazon has revised its variation themes policy for 2025. Instead of removing…
Reading Time: 8 minutesEvery sale you make online in the UK comes with a cut.…
Reading Time: 3 minutesHeads-up: eBay is changing what U.S. personal and financial data appears in…
Reading Time: 2 minutesAmazon has expanded Multi-Channel Fulfilment (MCF) and the broader Supply Chain by…
Reading Time: 9 minutesIt’s mid-October. The whiteboard is covered in timelines, SKU codes, and a…