0

we use the Update Attributes function a lot for adding extra attributes to the products.

Only the sort order of these attributes are based on oldest first (i think) Is there a way to re-arrange them?

Because the attributes which we update the most are about on 2/3th of the page ... so that means a lot of scrolling ....

I have added a screenshot with the 2 attributes i would like to have on top .... enter image description here

0

You can do some workaround in getAttributes() function of vendor/magento/module-catalog/Helper/Product/Edit/Action/Attribute.php class (don't forget to preference the class).

public function getAttributes()
{
    if ($this->_attributes === null) {
        $this->_attributes = $this->_eavConfig->getEntityType(
            \Magento\Catalog\Model\Product::ENTITY
        )->getAttributeCollection()->addIsNotUniqueFilter()->setInAllAttributeSetsFilter(
            $this->getProductsSetIds()
        )->join(
            'catalog_eav_attribute',
            'main_table.attribute_id = catalog_eav_attribute.attribute_id',
            'position'
        );

        if ($this->_excludedAttributes) {
            $this->_attributes->addFieldToFilter('attribute_code', ['nin' => $this->_excludedAttributes]);
        }

        $this->_attributes->setOrder('catalog_eav_attribute.position', 'DESC');

        // check product type apply to limitation and remove attributes that impossible to change in mass-update
        $productTypeIds = $this->getProducts()->getProductTypeIds();
        foreach ($this->_attributes as $attribute) {
            /* @var $attribute \Magento\Catalog\Model\Entity\Attribute */
            foreach ($productTypeIds as $productTypeId) {
                $applyTo = $attribute->getApplyTo();
                if (count($applyTo) > 0 && !in_array($productTypeId, $applyTo)) {
                    $this->_attributes->removeItemByKey($attribute->getId());
                    break;
                }
            }
        }
    }

    return $this->_attributes;
}

Here I have joined the catalog_eav_attribute table and sorted the attribute collection desc by the position of the attribute.

(Please note that the position attribute is used as "Position of attribute in layered navigation block")

You can do something similar for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.