This a question regarding Magento development, it can apply for both M1 and M2.
For the last weeks, I've been working on several modules that are directly related to native Magento entities/database table.
Here's an example but this is valid for several module development cases:
A module that lets you restrict a shopping cart rule for one customer only (described by the email).
I came to the conclusion that there's two possible ways of doing it and I'm wondering which one would be the recommended one:
First way: use Magento core tables
Never edit the core, is that applicable to core tables ?
- Add an
email
column to thesalesrule_rule
table - Applying the restriction can be done when the model is loaded.
Second way: use a custom table
- Create a custom table with
salesrule_id
andemail
linked to a custom model - Applying the restriction can be done by doing an extra join or load (of the custom model)
Back in the days I used to always modify the core tables directly but now I don't feel like this is the right way. However, I'm concerned about performance regarding the second way.
What is the best/recommended way of dealing with this ?