Whenever a Product/media is created an object_id needs to be created. So should i explicitly create a entry in object table and assign it to object_id in controller or do it in model in beforeSave method.
Also i don’t want product to be created if a object is not created. So if i am using 2nd way is there a way to prevent save of product if object is not created.
My preferred way is 2. Would like to know your thoughts on each one.
Create the Object record in the beforeSave() method in your Product/Media models. If the save() on the Object record returns false (=fails) then simply return false from beforeSave() and it will not save the Product/Media record.