Scenario wanted: Lets say you have multiple products that is on sale till a specific date each product with its own time and you want to create a promotion condition rule for all these products under one condition that the time is still valid.

This attribute is important to detect On Sale products and New products and can be used with many other extensions such as product labels extension or promotion rule extension because using default magento attribute it will be hard to refer to these products with valid time.

I am looking to create an extension that creates a product attribute with a value true or false (yes or no) but filled in programmatically according to the time "from" and "to" if it is valid and set the value to yes or no. So if the product is still on sale the attribute value will be yes. And if product is still new another attribute value will be yes.

Can any one help in creating such module.

For creating an attribute mageplaza offers a guide for it at: https://www.mageplaza.com/magento-2-module-development/magento-2-add-product-attribute-programmatically.html So in my case i want to create 2 attributes one for Sale and one for New and i want to fill this newly created attribute Programmatically according to time if valid or not.

  • I think you need to create cron for that and execute that cron as per your time. and load whole product collection and check one by one product is on sale or new. based on that you need to set your attribute value yes or no Nov 27 '19 at 2:27
  • yes you are right, but can someone share code how to do this. What to add for mageplaza attribute module to make it fill in attributes value automatically with cron?
    – moh moh
    Nov 27 '19 at 9:04

Your Answer

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

Browse other questions tagged or ask your own question.