Questions tagged [repositories]
The repositories tag has no usage guidance.
23
questions
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 ...
1
vote
2
answers
414
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 ...
0
votes
1
answer
226
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.
*
* @...
0
votes
2
answers
192
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
1
answer
29
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 ...
1
vote
1
answer
567
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
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->...
2
votes
0
answers
205
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
0
answers
70
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
1
answer
706
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
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 ...
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);...
1
vote
0
answers
613
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
1
answer
63
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
0
answers
149
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
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 ...
0
votes
1
answer
294
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
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 ...
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 ...
2
votes
1
answer
593
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
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 ...
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 ...
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 ...