Skip to main content

Questions tagged [repositories]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
30 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 ...
beluga's user avatar
  • 141
1 vote
2 answers
4k views

Upgrade magento 2.4.3 to 2.4.4

Hello after reading many threads i read that following are the steps in order to update magento with composer composer require magento/product-community-edition=2.4.4 --no-update composer update As ...
user3718303's user avatar
1 vote
2 answers
558 views

Avoid getting old data from customerRegistry in queue runner

We have a Magento 2 Queue Job which loads a customer /** @var \Magento\Customer\Model\ResourceModel\CustomerRepository */ $this->customerRepository->getById($this->customerId)); Now we ...
Alex's user avatar
  • 13.9k
0 votes
1 answer
248 views

magento 2 resource model "save" to implement service contract persistence operations. not saving POST empty

I have a custom rest api for PUT and POST that the post data is an empty array therefore not saving as it's empty can anyone advise why or what could be wrong? /** * Save data. * * @...
Juliano Vargas's user avatar
0 votes
2 answers
276 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 ->...
Paloma Martinez Ocegueda's user avatar
1 vote
1 answer
32 views

What are correct methods to implement in a repository?

What methods is a repository required to implement? The documentation (https://devdocs.magento.com/guides/v2.3/extension-dev-guide/service-contracts/design-patterns.html) states that you need to ...
guerinteed_mike's user avatar
1 vote
1 answer
647 views

Magento 2 Repositories and Database Transactions

Almost every post I read states that I should be working on objects using Magento 2 repositories rather that instantiating objects using Magento 2 object factories. That's what I started to do, and ...
Mark H's user avatar
  • 53
2 votes
1 answer
6k views

How to sort by position field

This is my collection function: public function getCollection() { $searchCriteria = $this->searchCriteriaBuilder->addFilter('status', '1')->create(); $someCollection = $this->...
Rufus's user avatar
  • 621
2 votes
0 answers
209 views

Joins on search criteria

Is thery any way to join other tables to SearchCriteriaInterface, while building it, before calling any getList method of any repository? I mean it should work more or less like joining tables on ...
Bartosz Kubicki's user avatar
3 votes
0 answers
78 views

How to join multiple repositories

Suppose if I want to join product repository and orderItem repository, then how can do that? There is way to join multiple collections (methods like join, joinRight, joinLeft, ...), how to do same ...
Anshu Mishra's user avatar
  • 8,990
0 votes
1 answer
803 views

Getting a table first row from repository

I'm building my first Magento 2 module, and I'm a bit stuck. First of all, this is what I have so far (I'm still fixing the coding standards on all the pages). https://github.com/moloni/magento2 I ...
Sunita's user avatar
  • 101
1 vote
1 answer
1k views

How to fix error in Web Setup Wizard - Command "show" failed: [Composer\Downloader\TransportException]

This is the error when I click on Extension Manager: Command "show" failed: [Composer\Downloader\TransportException] The 'https://repo.wyomind.com/packages.json' URL required authentication. You must ...
MicNet's user avatar
  • 51
0 votes
1 answer
2k views

Order Repository save not working

I am trying to associate orders and customer using the following code. $order = $this->orderRepo->get($oid); $order->setCustomerId($newCustomer->getId()); $order->setCustomerIsGuest(0);...
Anshu Mishra's user avatar
  • 8,990
1 vote
0 answers
680 views

Is it possible to clear registry of OrderRepository?

I have a mass action which saves hundreds of orders via OrderRepository. And sometimes the process fails with PHP Fatal error: Allowed memory size of XXX bytes exhausted Because save() method of ...
Ruslan Mavlyanov's user avatar
1 vote
1 answer
65 views

Magento 2 - Getting Order By ID hangs

I have the following class <?php namespace Company\Module\Plugin; class myClass { protected $_orderRepository; public function __construct( \Magento\Sales\Api\...
Goose84's user avatar
  • 2,621
1 vote
0 answers
152 views

Magento 2: Install module from multiple repositories

Today I've stumbled into a fairly intriguing issue. At the moment I'm building a module for a client and possibly I'll use it for future clients. Now, I would like to keep the core code in a ...
riofriz's user avatar
  • 11
0 votes
1 answer
23 views

Repositories and Methods

Does anybody have a link where I can find a list of all Magento 2.1 (or Magento 2) repositories and their methods? I tried to find this in Magento Devdocs and can't seem to find anything. Maybe I am ...
Rws's user avatar
  • 1
0 votes
1 answer
302 views

Custom Category Attribute not in Repository

I created a custom category multiselect attribute. (it's even a custom source but that does not matter). Everything is OK on save, admin forms OK, even the flat contains my values. ( thx to https://...
Pol Ravalitera's user avatar
2 votes
1 answer
41 views

Magento 2 : What's the proper location to put repositories?

In Magento 2.1: When I look at the customer module, I note that the customer repository is located in the folder for resource models: Magento\Customer\Model\ResourceModel\CustomerRepository But ...
Giel Berkers's user avatar
  • 12.3k
10 votes
2 answers
12k 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 ...
Bartosz Kubicki's user avatar
2 votes
1 answer
613 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, ...
enrico69's user avatar
  • 515
1 vote
1 answer
2k views

Console Command: Area code must be set before starting a session

I am trying to get a list of orders from the OrderRepository (Magento 2.1) via a console command and am using code as follows... ... public function __construct( \Magento\Framework\Model\Context ...
p3mbo's user avatar
  • 143
5 votes
2 answers
7k views

How to create store view or store programmatically and do it right in Mage 2?

I want to create store or store view programmatically and I use the followng code (for store view): $storeView = $objectManager->create(\Magento\Store\Model\Store::class); // Store - is a ...
Alex Gusev's user avatar
  • 2,039
4 votes
1 answer
2k views

Magento 2 product repository

In Magento2, I understood we have to use repositories instead of collections. What I do not understand is how to add custom attributes to repository. If I do something like this: $searchCriteria ...
Phoenix128_RiccardoT's user avatar