Questions tagged [design-patterns]
The design-patterns tag has no usage guidance.
11
questions
0
votes
0
answers
35
views
Define external objects in the constructor in protected variables
I don't think it is a pattern (if you have indicated it to me), but simply a way to improve the readability of the local classes, since Magento 1 does not have a management of the DI.
The approach is ...
3
votes
3
answers
492
views
What is difference between these models and design patterns used in Magento?
Yes, I know this question has many answers in google, but please clear my confusion.
What is the difference between Repository and Factory, and when should We use a Repository vs a Factory in Magento ...
1
vote
0
answers
31
views
Code Pattern to Define and Use Javscript Callbacks / Hooks
We are using a third party module, that updates prices via AJAX on product / category pages. No we have to react on this update, to update some custom pricing logic.
Of course we do not want to patch ...
26
votes
2
answers
18k
views
How many design patterns does Magento Have?
How many design patterns does Magento 2 have?
25
votes
1
answer
925
views
Are collections history in Magento 2?
I know that a lot of code that is currently in Magento 2 (2.1.2) is more or less ported from Magento 1 and that a lot of code will be substituted by an equivalent in the future. In this aspect, I'm ...
1
vote
1
answer
693
views
In Magento model do we have business logic or a controller?
I have read so many documentation about MVC. But I am still confused regarding the business logic in Magento. Can you please help me to explain business login in Magento with an example ?
-1
votes
1
answer
7k
views
What is the difference between Mage::getSingleton() and Mage::getModel() in Magento [duplicate]
Mage::getSingleton() always finds for an existing object if not then create that a new object but Mage::getModel() always creates a new object.
1
vote
1
answer
729
views
Where to place constants and/or module specific configuration
I have a module that needs smtp authentication information (host, email, method, password, port). I don't want to just hard code this. Where can I put this information where it will have some ...
2
votes
1
answer
116
views
Magento2 - Which namespaces to be used inside a class
This might be a novice question, but as when a developer starts to learn Magento2,how do i figure out which all namespaces must be used inside a Model,Block,Plugin or matter of fact any custom class ...
9
votes
1
answer
826
views
Magento 2: Creating Data Objects with Immutable State?
Dovetailing off a comment in another Magento 2
If you need to share some calculated value, put the calculation behavior to separate object and call it from blocks that require that value. Registry ...
15
votes
2
answers
2k
views
Magento2 factory pattern advantages over Magento 1
Magento 2 is using factory classes for non-injectables.
For example product class: ProductFactory
For example customer class: CustomerFactory
I don’t understand what is the type of factory pattern ...