2

Are default values for custom attributes taken into account at all?

  1. Create a yes-no/dropdown/text attribute, set a defautl value, add it to an attribute set.
  2. Open a poduct to edit it.

Expected result: The custom attribute has the given default value.

Actual result: The custom attribute has no value.

Why does this not work?

  • Can you share the code source please? Can you define verison of Magento – Mohamed El Mrabet Jul 16 '18 at 11:30
3

Default values won't be applied to the existing entities, a default value will only set on an entity when an entity is saved.

  • Would be nice if Magento could get this default value if the result of getData is null, seems a bit tedious to have to do this in a import or saving all products by hand. – DWils Jul 31 '18 at 22:09
  • @DWils You can write a custom script just to save the product. – Anshu Mishra Aug 1 '18 at 4:49
  • Yea but to do this for every product? Would take a long time if the store has a lot of products. It would be better if the indexer can find the default value if its not in the product. – DWils Aug 1 '18 at 17:36
  • @DWils Or you can write direct SQL query in your database to store the default value for existing products. – Anshu Mishra Aug 1 '18 at 23: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.