The answer is somewhat hidden in the Magento docs:
Extending a theme using _extend.less is the simplest option when you are happy with everything the parent theme has, but want to add more styles.
Read more here
Use _module.less when you want to make major changes in styles for a module and use _extend.less for minor adjustments. You'll find more examples on how to override component styles in the link above.
A Factory creates a Model. It's a design pattern (separate from Magento 2).
Typically, when you need to create a new instance of your class/entity, you would want a factory to create that. So instead of:
$product = new Product();
You would do:
$product = $productFactory->create();
Having a factory instead of using the new
-keyword has multiple benefits. For example:
- It allows for dependency injection when it comes to creating new instances (which is great for unit testing for example).
- It provides a hook into the constructing-process of your instances.
- It's more SOLID.
But you don't want to manually create all those factories by yourself (because it's boring and repeating most of the times). That's why Magento 2 uses code generation to create these factory classes for you. Just add Factory
after the class name in your use
-statement or constructor:
use Vendor\Module\Model\ExampleFactory;
or:
public function __construct(
Vendor\Module\Model\ExampleFactory $exampleFactory
) {
$this->exampleFactory = $exampleFactory;
}
Don't worry about warnings that the class does not exist by your IDE; Magento will create them for you. After a reload the class will be generated (in the var/generation
(2.1) or generated
(2.2) folder).
The only time when you want to create your own factory is if you want to apply some custom logic upon instantiating your object. But often that's not required.
Best Answer
First both InstallSchema And InstallData both method are called when you install any new module
It means it create new table and its fields with its structure.
Data setup is executed after Schema setup, they function in a similar fashion.