Questions tagged [repositories]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
107 views

How to sort by position field

This is my collection function: public function getCollection() { $searchCriteria = $this->searchCriteriaBuilder->addFilter('status', '1')->create(); $someCollection = $this->...
1
vote
0answers
101 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 ...
3
votes
0answers
45 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 ...
0
votes
0answers
17 views

Which are recommended to use while building search criteria for repositories?

Which class is recommended to use while preparing search criteria for any repository? Magento\Framework\Api\Filter or Magento\Framework\Api\FilterBuilder What are the differences between both of ...
0
votes
0answers
17 views

Avoid product duplication when trying to save from multiple ways

I am using Magento 2.3 version. I have a case to create the product from two XML when it hits my function. For example, I have two XML: A.XML and B.XML. Both XML will be triggered at a time or ...
0
votes
1answer
123 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 ...
0
votes
1answer
247 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 ...
0
votes
1answer
327 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);...
1
vote
0answers
156 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 ...
1
vote
1answer
37 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\...
1
vote
0answers
88 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 ...
0
votes
1answer
14 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 ...
0
votes
1answer
202 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://...
2
votes
1answer
35 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 ...
9
votes
2answers
4k 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
297 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, ...
1
vote
1answer
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 ...
4
votes
2answers
4k 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 ...
3
votes
1answer
1k 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 ...