1

I created a text type attribute called display_order with the following settings.

  • Catalog Input Type for Store Owner - Text Field
  • Used for Sorting in Product Listing - Yes

The display_order text for each product is 1, 2, 3, 4 ... and when the products display on the category page they're ordered as such.

However when I set Flat Catalog Product to "Yes" the display order gets changed to something else as shown in this article

Is there any way of fixing this, so with Flat Catalog Product set to "Yes" the display order doesn't change?

1
  • Good to see that your issue is resolved :) Jun 22 at 6:48
1

Since this attribute will not visible on frontend, you can change it's type to any other type.

The solution to this issue is you need to create attribute with type "Price" instead of "Text Field". You cannot change attribute type after creating attribute, so in order to do that follow this instruction

  • Delete old attirbute, i.e, display_order
  • Create new one with same attribute code display_order
  • While creating attribute set attribute type Price, this will work perfectly with numbers

Hope this will resolve the issue

#EDIT
To hide $ sign from product edit page include custom css file in app/code/Vendor/Module/view/adminhtml/layout/catalog_product_edit.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="Vendor_Module::js/custom_product_edit.js"/>
    </head>
</page>

in app/code/Vendor/Module/view/adminhtml/web/js/custom_product_edit.js you can hide $ sign, like this:

require([
    'jquery'
], function ($) {
    'use strict';
    jQuery(document).ready(function(){
        jQuery(document).ajaxStop(function () {
            jQuery('input[name=product\\[display_order\\]]').next("label").children("span").hide();
        });
    });
});
10
  • It seems to work, but is there any way of hiding the $ sign that shows up against the attribute on the backend product page? I found that this hides it but don't know where to put in in CSS. [data-index|=display_order] span { display: none; Jun 21 at 17:31
  • see updated answer Jun 21 at 17:47
  • Thanks, so I created a module and created the folders and files along with the etc/module.xml and registration.php and added this css into the product_edit_custom.css - [data-index|=display_order] .admin__control-addon label span { display: none; } It doesn't seem to hide the $ Jun 21 at 20:06
  • I have updated my answer, please try this solution, hope this will help Jun 22 at 4:10
  • When I check the page source the js file shows, but when I open it, it gives this error. Unable to resolve the source file for 'adminhtml/Magento/backend/en_GB/Vendor_DisplayOrder/js/custom_product_edit.js' <pre>#1 Magento\Framework\App\StaticResource->launch() called at [vendor/magento/framework/App/Bootstrap.php:261] #2 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\StaticResource#0000000079d1a7a4000000000cccda37#) called at [pub/static.php:13] </pre> Jun 22 at 5:07

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.