Linked Questions

0
votes
1answer
45 views

What is Factory in Magento2 and Why use? [duplicate]

What is Factory in Magento2? Why use this. I want to know more details about Factory. When we can use Factory.
0
votes
1answer
37 views

What is Repository in Magento2 and Why use? [duplicate]

What is Repository in Magento2? Why use this. I want to know more detail about Repository.
24
votes
3answers
4k views

Is there ever a reason to prefer $model->load() over service contracts?

I understand that the preferred way to work in between modules in Magento 2 is using the service contracts. So if I want to load a product, I use the product repository: $product = $...
8
votes
3answers
8k views

Get product collection with product ids

Is it possible to get a product collection bassd on array of product ids?
9
votes
2answers
3k views

What and why is the proper way to load a model

I have quite a lot of experience with Magento but I realized that I don't understand which way of loading a model is the correct one and why. I've read everything that I could, about the topic but ...
5
votes
1answer
4k views

Filter product collection by sku or name

I have a variable which containing value to filter both name or sku, i tried to filter the product collection using this variable like this: $queryName = 'bat'; $category = $this->_categoryFactory-...
4
votes
1answer
3k views

Magento2: Difference between Factory and Repository

What is the difference between these two objects in magento2? (Factory and Repository) I have seen that they have almost the same methods. What proper use does one have?
4
votes
2answers
954 views

Magento 2: When should we use a ProductRepository, ProductFactory, Product model?

When should we use a ProductRepository, ProductFactory, Product model? vendor/magento/module-catalog/Model/Product.php vendor/magento/module-catalog/Model/ProductRepository.php generated/code/...
4
votes
2answers
527 views

Magento 2 - what functions can I use?

Recently I've went through the "Fundamentals of Magento 2 development" course and there was such statement that we SHOULD NOT use functions from other modules that are not defined in the API ...
0
votes
1answer
1k views

In Repository, how to replace deprecated load() function?

I know we should use service contracts(Repository) over $model->load(), but in Repository itself, how to replace the deprecated load() function? For example, in Magento\Cms\Model\PageRepository, ...
0
votes
3answers
1k views

Correct way to save entries to database

I want to know, what is the correct way to implement CRUD operations in Magento 2? because I found a lot of examples but they use deprecated methods. I created a table ('quote reserved item') with ...
1
vote
1answer
2k views

How to load model without $objectManager and without inject dependencies?

I am reading that I should never use $objectManager directly to load model $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $subscriber = $objectManager->get('Magento\...
2
votes
3answers
207 views

Difference between load() and get() methods

While going through the Magento code I have been seeing a lot of instances of: $objectName->load($foo) or $objectName->get($foo) and I was wondering, what is the difference between the 'load'...
1
vote
2answers
200 views

Magento 2 Extension installData script in modelFactory is necessary?

I'm working on magento2 custom module. i have to install some data in my custom_table. so i am referencing below script. i know the idea about $postFactory as describe here Magento2: How to add pre ...
0
votes
1answer
137 views

What is the best method to retrieve a SINGLE ITEM order details in Magento2?

I am currently using the \Magento\Sales\Model\OrderFactory $_orderFactory and loadByIncrementId($id) in my custom block and calling it in my .phtml file. I get basic details of the order, but I ...

15 30 50 per page