Questions tagged [repository]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
426 views

How to load a model with relationships via repository in Magento 2?

Background story: I was trying to load a model with model_store relationship using this snippet. I failed to do that with my own model. Model is being loaded without store data. Some debuging later I ...
0
votes
1answer
334 views

Magento 2 doesn't resolve my own Repository Interface in the custom module

I'm trying to create a custom module for Magento 2. when I try to inject the ThreadRepositoryInterface into the controller constructor the code fails. This is the error: Fatal error: Uncaught Error: ...
1
vote
0answers
345 views

Product repository - get methods' store id argument = null

If I do not provide $storeId argument for methods get() or getById what store id would be used? Default? Or current? If I DO use this argument we can see that it will be set and data specific for ...
4
votes
1answer
1k views

Resource Model vs Repository in Magento 2

I am quite confusing on the concept of Resource Model and Repository in Magento 2. Are they both responsible for managing the persistent storage, like MYSQL? Let says I would like to get specific ...
84
votes
5answers
25k views

When Should We Use a Repository and Factory in Magento 2?

I have gone through a couple of tutorials in Magento 2, and this confuses me a little. I can see there are basically two ways by which we can read/write business entities: Retrieve Data Using A ...
4
votes
1answer
2k views

'Option values are not specified' when saving configurable

I have a product import routine which calls $this->productRepository->save($product); but it's failing with the following error: [Magento\Framework\Exception\InputException] Option values are ...
0
votes
1answer
49 views

Alternative to move a tree type entity instance without calling $entity->move()

I'm trying to build a tree behaving entity similar to the categories in Magento 2. Of course I used the Catalog category entity as an example, but this works up to a point. I'm planning to implement ...
2
votes
0answers
1k views

Add image to product programatically not using addImageToMediaGallery

Method addImageToMediaGallery() seems to me buggy, when using productRepository to save product, what encourage us to use deprecate method save() directly from product model (what causes other bugs), ...
25
votes
1answer
815 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 ...
2
votes
1answer
978 views

Magento 2: save product description for adminhtml programmatically

I cannot see description and short description attributes of the product in adminhtml after saving: /** @var \Magento\Store\Model\StoreManagerInterface */ protected $_manStore; /** @var \Magento\...
0
votes
0answers
526 views

Magento 2 - SortOrder class not found

I have created a repository to retrieve records from database. I need to sort the records using a specific column. I tried to use the SortOrderBuilder but it returns Fatal error: Class 'Qooar\...
2
votes
1answer
80 views

Repo with sources for Magento 1

Where is the source code repo for Magento 1? I want to post PHP7 incompatibility fix for the latest version (1.9.2.4).
10
votes
2answers
6k views

How should I save new or updated entities of models?

In Magento 2 we have repositories classes. Classic method save() used heavily in Magento 1.9 are deprecated, if I am correct, from 2.04 or 2.05. I was using factories to create new object and after ...
1
vote
1answer
384 views

Magento 2: links between entities: best practices

I have a question regarding link between entities. Consider that a car is linked to a brand. The car entity will have a brand_Id attribute. Coming from the "Symfony universe", using the Doctrine ORM, ...
0
votes
1answer
212 views

REST API Not saving products Magento2

Using the REST api of M2 and for some reason I can't save a new product ? Here's my code Here's the error I get. Any suggestions?
2
votes
3answers
1k views

“URL key for specified store already exists” when updating an existing product?

I am getting the above error on a limited number of products, when loading and saving them with this code: $product = $productRepo->get($_sku); $product->setStockData(['qty'=>$new_qty,'...
6
votes
0answers
497 views

_origData is null for some models in Magento 2 before or after save

Let's get a customer save process from the admin panel as an example. We have an event observer for model_save_before and trying to get a set of values for the model that have been changed upon the ...
3
votes
2answers
5k views

How to join a table with a Magento 2 repository

I am trying to extend inventory stock items by joining my own table with added information. When the product page is loaded it gets the stock item via StockItemRepository::getList($criteria). So I ...
6
votes
2answers
953 views

Can the NPM fiasco happen to Magento 2?

As some of you may know, a huge fiasco happened a month ago with NPM As of now, Magento 2 composer.json file includes a lot of external resources (details on the Magento 2 GitHub) What if one of ...
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 = $...
3
votes
1answer
3k views

Magento 2: Can you Filter By store_id Using a Product Repository

In Magento 2, it's not possible to add a store_id filter to a product collection directly. Instead, you need to use the addStoreFilter method, which adds a special "product limitation filter". It ...
12
votes
2answers
10k views

Magento 2: Product Repositories, Filter Groups, and `AND`

I'm trying to use a product repository to fetch a list of products. I want to fetch based on two filters, combined with an AND criteria, but things don't seem to be working. Do I not understand how ...
24
votes
2answers
24k views

Filtering a Magento 2 Object Repository

In Magento 2, can you use a product repository to filter by product attributes? In Magento 2, you can use a search criteria object \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria, ...
0
votes
1answer
700 views

My Custom Module API Data not saving in magento 2

I have created a custom module (Blog) which contains a save() method, it is executed but values are not saved and it returns an empty object. <?php namespace Learning\Blog\Model\Resource; use ...

1
2