Questions tagged [repository]

The tag has no usage guidance.

36 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
1answer
525 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 ...
5
votes
0answers
88 views

StoreRepository get($code) which does not exists

Till today all the code was okay, but after code review, I got that we use the method load() on the store itself so I replaced it with storeRepository->get($code) Code what I'm talking about ...
4
votes
1answer
282 views

Update select attribute in custom_attributes via catalogProductRepositoryV1 API PUT request

I'm trying to update a product with the catalogProductRepositoryV1. I want to change a custom select attribute for the given product. When sending the following request: { "product": { "...
4
votes
0answers
147 views

How to handle multiple tables with magento 2 repositories?

As we all know, magento 2 suggests using repositories as an additional layer between resource models/collections and the rest of application. It's all pretty straightforward and simple when you use it ...
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 ...
3
votes
1answer
294 views

2.2 Pipeline deployment

I was reading on the new Pipeline deployment here but I don't understand how this is supposed to work in a repository. In developer mode static content is dynamic, but if the build system commits ...
2
votes
0answers
17 views

Logical "NOT" in SearchCriteria

I found how to use logical "AND" & "OR" in search criteria: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/searching-with-repositories.html https://devdocs.magento.com/guides/v2.3/...
2
votes
0answers
26 views

taxClassId are not saved with the rest of the product

I'm trying to update some attributes of my product by a cron to avoid common mistakes. The code causing me trouble is executed in a loop: foreach ($storesIds as $storeId) { $this->...
2
votes
0answers
624 views

Magento2 Compile command ends at Repositories code generation 1/7

Magento v2.1.7 CE PHP 7.0 Permissions double checked When I run compile command through cli, it ends at step 2 as seen in the image below. I found that it might be due to a wrong auth.json in ...
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), ...
1
vote
0answers
71 views

how to join custom table in sales order table \Magento\Sales\Model\OrderRepository magento 2

i want to join custom table in repository in magento 2 but i tried this tutorial (blog) https://fishchenko.com/blog/magento-2-join-table-in-orderrepositorygetlist-custom-field/ it was not clear is ...
1
vote
1answer
107 views

Magento 2 - What should repository methods return?

This question has been on my mind for some time. I'm currently writing a repository with the usual methods: save, getById, getList, delete and deleteById. What is the correct return for each method? ...
1
vote
0answers
316 views

Magento 2.3 Composer stuck while downloading https://repo.magento.com/packages.json

I have a problem since about 24 hours I guess. When I try to download Magento 2 with composer I stuck after logging with my user-credentials. The credentials are ok, it pass and go through the next ...
1
vote
0answers
52 views

API issue returning object

We have this API where we save different fields, but the object $lines we have created doesn't save properly. The code below are the getters and setters for the object $lines. Save method API: ...
1
vote
0answers
24 views

Magento 2 REST API create for post operation

I am a newbie in Magento. I am trying to create a Magento Rest API for post operation.I go through many online resources but none of it clarify my doubt. I am trying to create an API for an operation ...
1
vote
0answers
31 views

Magento 2 BlockRepository.php can't understand code

I'm newbie at Magento 2, and trying to study and research code to use all business logic for my future work. I found method getList at BlockRepository.php at https://github.com/magento/magento2/blob/...
1
vote
1answer
84 views

SetId on category results on exception

I would like to set my ID on the category Category::setId but this results in the following exception: "No such entity with id = x". My code: $catFactory = $objectManager->get(CategoryFactory::...
1
vote
0answers
799 views

How to manage custom attributes in group customer

i'm new in the magento world (and php community). I want to add some attributes to custom group in magento 2.2 I've created a new attribute by setup (his name is : 'exchange_id') : use Magento\...
1
vote
1answer
495 views

productRepository->getCustomAttribute('attribute_code');

I need to retrieve 1 product attribute value from 1 product, I wonder if using the product repository in this way is the most effective in terms of performances: $productColour = $this->...
1
vote
0answers
615 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 ...
1
vote
0answers
400 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 ...
1
vote
3answers
4k views

How can I check if a product exists in Magento 2 without throwing \Magento\Framework\Exception\NoSuchEntityException?

I'm attempting to scan an incoming list of products and add any new ones to the catalog. Therefore, I must run a check on each product to see if it already exists. I'm using a ...
0
votes
0answers
13 views

How to get Identity of recently inserted for Resource Save *(Magento 2.3.5)

The answer linked here mentioned (in the comments more specifically) that I am supposed to be able to get the Id from the repository/resource), it also more importantly confirmed that $model->save()...
0
votes
0answers
6 views

Get your authentication keys getting Fastly is validating your browser

I am trying to get my authentication keys i go to :https://marketplace.magento.com/customer/account and get "Fastly is validating your browser" I have a clean cache also try to get it from ...
0
votes
0answers
27 views

Product collection and Product Repository return different results

I am a little confused about the difference between getting products by Collection and use de Repository. Right now, in one project, if I run this code: $collection = $this->_productModel->...
0
votes
0answers
165 views

Category with id XXX not found

I work on a multi store website <=> One website for 2 stores. (Actually I have more websites but it's irrelevant). Each store have his own default category and categories. So as Store A has ...
0
votes
0answers
53 views

Load customer by ID in Helper/Class or Model/Class | Magento 2

I can load in controller with: \Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface, as: $customer = $this->_customerRepositoryInterface->getById(1); and using ...
0
votes
1answer
92 views

Cannot update product name using productRepository in Admin Store ( Store 0 )

I'm trying to update a product using productRepository ( migrating from a flow using product factory with load ). Problem is tha when updating the name it is updating in store 1 ( default store ) but ...
0
votes
1answer
20 views

I getting the Error on product page magento 2.3

I tried to update the product using REST API but it shows the page this like i can't recognise the error please any one help to resolve it. Header : rest/all/V1/products/SKU My API : { "product":{ ...
0
votes
2answers
33 views

Sorting repository by more than one attribute

I want to sort a repository by more than one attribute. Any ideas of how to achieve this? What I have so far is this: public function getLatestPosts() { return $this->postRepository ->...
0
votes
1answer
324 views

Should Magento\Eav\Model\AttributeRepository save 'used_in_forms' attribute value?

I add EAV attribute to a customer address. I can use \Magento\Customer\Model\ResourceModel\Attribute $attributeResource to save the attribute. According to Magento DevDocs https://devdocs.magento.com/...
0
votes
1answer
360 views

Download failed, retrying... Downloading https://repo.magento.com/archives/magento/magento2-base/magento-magento2-base-2.3.0.0.zip

I need to say, its really hard and sadly magento typically that nothing works out of the box as it should if you follow offical step-by-step tutorials. Since a few hours or better days I try to ...
0
votes
0answers
75 views

Deleting Product gives StateException (code:0)

The codes: public function __construct ( ProductInterfaceFactory $product_factory, ProductRepositoryInterface $product_repository, Registry ...
0
votes
1answer
446 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: ...
0
votes
0answers
588 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\...
0
votes
1answer
277 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?