Setting some of the new product attributes to 1 instead of null when creating the product



  • What is the best way to set ["new", "visible_individually", "featured", "status"] attributes to 1 on the creation of the product? I mean to be activated once the user creat the product and move to the edit product interface.
    I noted that the data on the product edit is fetching the values from the product_attribute_values not product_flat. product_attribute_values only gets created on the calling the product update. Therefore changing the database default setting won't do the trick.
    Thanks.



  • Hi @squirrel,

    May I know what are you trying to do because in Bagisto, all values are saved in product_attribute_values tables and for fetching or displaying records we are using product_flats table to avoid multiple join queries.



  • When you create a product, by default "new", "visible_individually", "featured", "status" values in the
    /catalog/products/edit/{id} page are set to NULL. How can I make them set to 1 for all newly-created products?



  • @squirrel,
    You need to set the value in both tables at the time of creation.



  • You need to set the value in both tables at the time of creation.



  • Hi @devansh-webkul @harukovn, do you mean I update the migration file or change the code for that? If it's about changing the code, could you point me to the methods that I have to change, please?

    Thank you


Log in to reply