Questions tagged [best-practice]
Denotes questions related to best-practices in Magento.
210 questions
0 votes
0 answers
28 views
What's the actual best-practices way of displaying a list of things (products, etc.), such that each instance is a block with its own template?
I'm essentially just wondering what's the right way (if possible) to create a module that has a block which represents a list of things (could be products, images, whatever), but instead of having the ...
0 votes
1 answer
55 views
Why do some core repositories use a data model in the save function while others use a model?
I have a quick question and this could help me determine what is the good practice using the repositories. To provide an example to the question I ask in the title of this subject, I can take as ...
0 votes
1 answer
76 views
Magento 2 Coding Practice
recently I came across one developer's code in magento 2, where he was accessing objects in another class to avoid dependency injections. Like for example we have Vendor\Feature\Helpler\Data class and ...
0 votes
1 answer
1k views
Magento 2 - Best practices - Helper vs Model : Which one to get config values?
I cannot seem to find an official information about what is the recommended way to retrieve configuration values in Magento 2. I am searching for the recommended way to retrieve values from the ...
0 votes
1 answer
588 views
Using Env.php to Override Module Status in Config.php
What I am trying to achieve is overriding specific modules declared as enabled in the app/etc/config.php to be disabled by the app/etc/env.php file. A use case of that would be the 2FA module which I ...
0 votes
1 answer
82 views
Getting a Product model from db
I've just started in the world of Magento and throughout the process of many questions I have came across one its proving dificult to find the best description for it. Considering the following ...
0 votes
1 answer
1k views
Adding an Extension Attribute to Sales Order Items - Magento 2
I have created some custom attributes for products and using these attributes in order view in customer account orders section. I have deleted few products. When I view the customer orders, it gives ...
0 votes
2 answers
348 views
Indentation Style (Code style) Magento 2
Hey, I wanna check if there is some documentation about the code style for magento, specially regarding the best practices Indentation style for magento. I will give 2 examples, and I wanna also know ...
0 votes
1 answer
919 views
What is the best way to override constructor of a class - Magento 2.4.3
I want to make a single line change in the constructor of a core class. What would be the best recommended practice to achieve it. Here is what my existing constructor /** * Download constructor. ...
0 votes
1 answer
44 views
how do i make an admin grid based on sales_order table (some columns but not all) using best practice?
Let's say I need an admin grid where not all columns of the sales_order table will be, but only some of them. For example: customer_id customer_name nickname How best to solve such a problem?
0 votes
1 answer
439 views
The best ways to practice Magento 2 when not in work
Any recommendations for how to practice Magento 2 when not working? i.e. it's easier when working as you're presented with real life task, issues, clients etc. but when practicing at home, I'm just ...
0 votes
1 answer
232 views
Join array values and keys between two php arrays
I need to merge (sort of join) two arrays with both same keys, and in result i want to have the values of the first as keys of the second one : Example : $keyArray = [ "key1" => "...
4 votes
0 answers
577 views
Implementation of Composition Instead of Inheritance in Controllers Magento 2
I am trying to implement Magento 2 Coding Standard so I found an Article Here -> https://community.magento.com/t5/Magento-DevBlog/Decomposition-of-Magento-Controllers/ba-p/430883 I have changed my ...
1 vote
0 answers
91 views
Should I be integrating Babel with the frontend javascript in my Magento2 module?
I created a magento 2 module which is using mostly javascript. I want to know what is best practice for implementing backwards compatibility across older browsers in magento2.
1 vote
2 answers
185 views
Current best practices for controllers
Now that we're not supposed to extend Action\Action anymore, is the current best practice to create a separate Controller for each CRUD action? One for create, one for delete etc?