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

Created on 20 Feb 2020  路  7Comments  路  Source: magento/magento2

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

Catalog CatalogSearch LayeredNavigation ready for confirmation Reported on 2.3.4

Most helpful comment

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.

All 7 comments

Hi @drew7721. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@drew7721 do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [x] yes
  • [ ] no

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.

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.

It seems this has been reverted? https://github.com/magento/magento2/commits/2.3/app/code/Magento/Catalog/Model/Layer/FilterList.php (again without any form of communication).

@Swahjak yes I believe that this was reverted. Sorry that it wan't communicated with you after the internal ticket was finished.

Is there a fix for this?

Ideally with numeric input slider filter.

Issue can probably be closed since the reversal of the code which introduced the bug was included in Magento 2.3.5. @drew7721 or somebody else, could you confirm this?

Was this page helpful?
0 / 5 - 0 ratings