magento2: Unable to create a product attribute of type Decimal for products on 2.3.4

Preconditions (*)

  1. Magento 2.3.4

Issue

The issue is with the Decimal product attribute. I believe this has been an issue for a while now but I can’t seem to find a proper ticket describing this issue.

Say you need a product attribute such as volume that would be decimal values such as liters. There is no actual Decimal attribute, so it’s determined that we’ll use price instead.

Before 2.3.4 there was code in place that would check the backend type and use the Decimal filter class instead of the Price filter class in the layered navigation. That code has now been changed and the decimal class will never be used. It will always fall on the price.

Now, if we do set such an attribute, it will show on the frontend as a price range. But that’s not all. It will also use the price class, not the decimal class. Hence, if the values are then removed, it will keep showing the attribute on the front end with a value of 0 or above.

If we do however make the change directly in the database or add the attribute trough code and set the frontend type to decimal, then the product page will no longer load in the admin because it will throw an error.

Steps to reproduce (*)

  1. Make a price attribute that you want to show as a range
  2. Can’t set it to show as decimal instead of price
  3. Set values for it. See how it displays (with currency, but another issue for this is already opened)
  4. Remove values for it. See how it does not go away
  5. Set the frontend_input in the database table eav_attribute to decimal
  6. Admin product page no longer loads and front end values are not showing properly.

Expected result (*)

  1. To be able to create a decimal attribute and use the proper filter class for it.

Actual result (*)

  1. Unable to create a decimal attribute not use the class assigned to it.

Notes

Now, I know that the decimal attribute type has always been an issue and it seems like it will remain that way. I’m also aware that the whole layered navigation and search criteria will be deprecated and it’s said that elastic search will be the default searching and filter engine for 2.4.

Regardless, I still believe this should be fixed. Since the price workaround did work up until 2.3.4 it would be nice to either have it set back or properly fixed in 2.3.5.

In my opinion, the whole Navigation/Filters section should be revisited and refactored to a more friendly approach. But that’s just me.

Just as a reference, there’s this issue as well that’s related to the attribute filter but that’s a whole other issue. https://github.com/magento/magento2/issues/16453

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

And there we go, another BC break in a minor release. I completely support the arguments written by @drew7721. @krissyhiserote there are many use cases for decimal attributes and ever since I know Magento there have been widely used custom solutions available to solve this gap (Amasty’s Improved Layered Navigation, Smile Elasticsuite). It’s one thing to not support decimal attributes, but killing them all together seems like an unnecessary step.

There is no Decimal Product Attribute in 2.4 develop. image

How can I modify the attribute in the database? Should not have to modify it in the DB anyway decimal should be an option that can be selected in the Admin right?

Useful for all sorts of things… Sizes, Voltage, Amperage other units etc… which would be great to have range slider filter options and able to be searchable/filterable…

Range search in product catalog.

A decimal input is letting you write numbers like 5.234 in the admin for product and to import such numbers using rest api or bulk importer.

Maybe a way to set precision and length.

On Fri, 24 Sep 2021, 8:59 am Vlad Veselov, @.***> wrote:

@LiamKarlMitchell https://github.com/LiamKarlMitchell what kind of input type do you expect for decimal attribute? Do you see specific input type for integer attribute here? 😃

Hint: check existing in the system integer and decimal attributes.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magento/magento2/issues/26949#issuecomment-926152819, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPAP3JMONFZBB5Z56VWPG3UDOIJNANCNFSM4KYS33VA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

I think it’s important we see the origin of this conversation at the commit itself. Thanks, @drew7721, for ensuring my faith in the framework remains consistently low. Good catch.