Questions tagged [repositories]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

There is a limitation to use a custom repository class when it is used in a cron job?

Using Alan Storm's pestle libary, created a full crud model, which it created its interfaces, repository, model, resource model and collection, nice. Defined a new cron job in the crontab.xml, ...
0
votes
2answers
25 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 ->...
1
vote
1answer
18 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 ...
0
votes
1answer
84 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 ...
2
votes
1answer
570 views

How to sort by position field

This is my collection function: public function getCollection() { $searchCriteria = $this->searchCriteriaBuilder->addFilter('status', '1')->create(); $someCollection = $this->...
2
votes
0answers
133 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
50 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
1answer
206 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 ...
1
vote
1answer
521 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
549 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
214 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
41 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
101 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
16 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
216 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 ...
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
389 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
5k 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 ...