Skip to main content

Questions tagged [repository]

The tag has no usage guidance.

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

Issue with custom extensible entity and getList method from repository

I have a custom extensible entity: interface that extends ExtensibleDataInterface with get and set; model that extends AbstractExtensibleModel with get and set; My GetList method from repository: ...
Dramorian's user avatar
0 votes
0 answers
26 views

List products including out of stock products in custom module (without listing out of stock products on the whole shop!)

I’m having a custom route in a custom module where I’d like to list a subset of products for a specific search criteria. I’d like to include here just for this action the out of stock products. BUT I ...
denis's user avatar
  • 101
0 votes
3 answers
109 views

How to persist the value of a custom field on the customer_entity table?

I'm new to Magento 2 and to this forum. I'm trying to add a newsletter subscription on the customer menu, just after the core one. For that, i created a module "ACME_Newsletter" I added a ...
jlegrand79's user avatar
0 votes
1 answer
524 views

How to save data to database using interface repository api

I'm a newbie magento 2 developer. I'm currently learning how to store data to database using repository-interface-model-api approach. My code is not working. model ItemRepository class ...
jsnewbie21's user avatar
0 votes
1 answer
39 views

How to get all Products of all Websites/Stores?

I tried getting all products of all websites via the ProductCollection like this: $stores = $this->storeManager->getStores(); foreach ($stores as $store) { try { ...
Max's user avatar
  • 17
0 votes
1 answer
55 views

Where should I connect model-data-access?

I am building a custom feature to create lists of favourite products. For this purpose I have created 2 models: The actual list-entity and a model representing information about a single product. For ...
Hurrpadurr's user avatar
0 votes
1 answer
304 views

difference between collection and repository in magento 2

I am not understanding the concept difference between collection and repository in magento2 and which is better to use. your help will be able to appreciate.
Muhammad Zahoor's user avatar
0 votes
0 answers
711 views

Magento 2 filter products collection by category and other attributes using filterBuilder

I'm trying to use a product repository to fetch a list of products. I want to fetch based on multiple filters (category_id, name, description and short description), combined with an OR criteria, but ...
mshifo's user avatar
  • 1
0 votes
2 answers
407 views

Change magento cloud project repository

we need to change the repo that a magento cloud project uses. Like if we were migrating from GitHub to BitBucket. How could we do that?
Natalia schlesinger's user avatar
0 votes
1 answer
866 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()...
CvRChameleon's user avatar
0 votes
1 answer
167 views

How to override OrderRepositry - save function | API

I need to add some custom functionalities in the Order save function when some API request comes. To be exact need to override the core OrderRepository class vendor/magento/module-sales/Model/...
Sathya's user avatar
  • 518
0 votes
1 answer
466 views

ResourceModel->delete() not deleting row in custom table

I am writing a module which imports additional product information into a custom table with SKU as the PK. If there is already a row in the custom table regarding the SKU, i have to delete the old row ...
Max's user avatar
  • 17
1 vote
1 answer
462 views

What is the difference between Collection & Repository & Factory classes?

I am trying to understand when to is use which according to the best practice. for exg. To get some data like (product,customer) what should be used Collection ? To set some data into product etc what ...
dev php's user avatar
  • 45
0 votes
3 answers
450 views

Magento 2 how to work with CMS blocks and CMS pages on repository?

I have created many blocks but as far as I know only by exporting them from database is the only way to have their code. Is there another way to have the files? because pushing and commiting .sql to ...
Oscar Vazquez's user avatar
0 votes
1 answer
938 views

Unable to change product status - for "All store views" (Global Store)

I am in need to disable a list of SKUs. For that I have created a console command, read the CSV and then setting product as disabled. I am facing an issue that I am not able to make product disabled ...
Narendra Vyas's user avatar
1 vote
0 answers
229 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 ...
prabhakaran7's user avatar
  • 1,097
0 votes
1 answer
703 views

Save multiple repository with rollback(if any error)

I need to save multiple repository like this, but I need to use to save Id of first repository in second repository and third and fourth one, so I think I can't use the link example with repository. ...
Max's user avatar
  • 323
0 votes
1 answer
1k views

Delete all entries in a custom table programatically

I'm using magento 2, I created some tables that I fill with entries then I want to delete all those entries at once. I want the solution to use Magento repository abd without using a foreach. ...
malek yahyaoui's user avatar
0 votes
0 answers
248 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 ...
Ajwad Syed's user avatar
  • 1,591
0 votes
1 answer
370 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 ...
sarakinos's user avatar
  • 251
0 votes
1 answer
27 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":{ ...
Sabareesh's user avatar
  • 358
1 vote
3 answers
3k views

Invalid credentials for repo.magento.com

I'm trying to install Magento 2.3 on a local Laragon install, but the composer install is failing because of this error: [Composer\Downloader\TransportException] Invalid credentials for 'https://...
Matt Krell's user avatar
0 votes
1 answer
763 views

Magento2 - Exception occurs when I update customer data using customer repository

Error: Invalid value of UK provided for the countryId field. Error File: vendor\\magento\\module-customer\\Model\\ResourceModel\\AddressRepository.php Error line: 133 Code is: $customer = $this-&...
Ghulam Akbar's user avatar
2 votes
1 answer
121 views

What PHP class executes the SQL to select models and collections from the database?

When I have a PHP model or collection of a Magento entity (such as a product or customer), what PHP class(es) is in charge of constructing and executing the SQL that selects that model or collection ...
Ben Rubin's user avatar
  • 549
0 votes
3 answers
334 views

Can somebody give me a tutorial link to install magento on Centos8?

Can i get a link to some kind of tutorial that works for installing magento 2 on centos 8 i try to follow what is currently on google but they dont work.
Wed's user avatar
  • 13
0 votes
2 answers
274 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
2 votes
0 answers
52 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/...
Alex Gusev's user avatar
  • 2,019
1 vote
1 answer
122 views

Is product repository in Magento the optimal way to read product url

I am reading a core function in Magento 2.3, the function is \Magento\Wishlist\Helper\Data::getProductUrl * Retrieve URL to item Product * * @param \Magento\Wishlist\...
Herve Tribouilloy's user avatar
1 vote
1 answer
256 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? ...
Radu's user avatar
  • 460
2 votes
1 answer
1k views

Magento 2 - Custom Repository does not create new entity

I create a custom entity and repository. All work well, but the POST API route does not create new entities. But if I call the PUT API route to change a property, it works well. Why my custom ...
Mirko Rapisarda's user avatar
5 votes
2 answers
4k views

Magento 2: When should we use a ProductRepository, ProductFactory, Product model?

When should we use a ProductRepository, ProductFactory, Product model? vendor/magento/module-catalog/Model/Product.php vendor/magento/module-catalog/Model/ProductRepository.php generated/code/...
Dj3's user avatar
  • 101
0 votes
2 answers
48 views

Create QuestionManagement class

I have made Question repository class: namespace Vendor\Module\Model; use Magento\Framework\Api\DataObjectHelper; use Magento\Framework\Api\SearchCriteriaInterface; use Magento\Framework\Api\Search\...
Rufus's user avatar
  • 621
3 votes
2 answers
2k views

Magento 2.3.0 How to add store filter in searchCriteriaBuilder

In my custom module, I am trying to add store filter in orderRepository using searchCriteriaBuilder but it is throwing an error like below. 1 exception(s): Exception #0 (Exception): Warning: PDO::...
Chirag Patel's user avatar
  • 6,156
0 votes
1 answer
782 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/...
Boris Ruvinsky's user avatar
2 votes
0 answers
29 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->...
JeremyC's user avatar
  • 21
4 votes
1 answer
615 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": { "...
Alexander Hälbich's user avatar
0 votes
1 answer
494 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 ...
Timm K.'s user avatar
  • 41
2 votes
0 answers
360 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 ...
Timm K.'s user avatar
  • 41
1 vote
0 answers
57 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: ...
chdzma's user avatar
  • 952
1 vote
1 answer
103 views

Add to cart not working in custom template magento2

I am getting add to cart url by product object like below. Block file. use Magento\Catalog\Api\ProductRepositoryInterface; use \Magento\Checkout\Helper\Cart as CartHelper; class CustomAdd ...
Jafar Pinjar's user avatar
  • 1,949
5 votes
0 answers
151 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 ...
Jarzebowsky's user avatar
1 vote
1 answer
364 views

custom extensions - are hyphens allowed in the Extension name?

This is a follow up on the Magento 2 Extension naming convention question here. I've learned thus far that you need a Vendor Name an Extension (or Module) name a combination of both like ...
vrms's user avatar
  • 115
1 vote
0 answers
40 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 ...
Magento Learner's user avatar
1 vote
0 answers
34 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/...
Alex Belkin's user avatar
1 vote
1 answer
67 views

How To Avoid Using the Save method with custom objects in Magento 2

The save method of AbstractModel is marked to be deprecated, for this reason I try to avoid using it. Normally I do this by using a repository. That's fine for things like orders which Magento ...
Ewan McRobert's user avatar
2 votes
1 answer
780 views

Update Product programmatically - Invalid method Magento\Eav\Model\Entity\Attribute::isScopeGlobal

I have a quite simple piece of code (reduced it to that): try { $newProduct = $this->productRepository->get($productData['sku']); echo 'Loaded.' . PHP_EOL; $savedProduct = $this->...
hey's user avatar
  • 1,137
0 votes
0 answers
98 views

Deleting Product gives StateException (code:0)

The codes: public function __construct ( ProductInterfaceFactory $product_factory, ProductRepositoryInterface $product_repository, Registry ...
Farid's user avatar
  • 103
0 votes
1 answer
10k views

SearchCriteriaBuilder->addFilters() using multiple filters

As per title. This what I've done: $filterCode = new Filter(); $filterCode->setField('SpecialCode') ->setValue('') ->setConditionType('null'); $filterItemId = ...
farid JAD7's user avatar
3 votes
1 answer
4k views

Customer Repository Interface, Limit Results

I'm trying to grab the oldest customer, using the customer repository from the database. Here's my code so far: // if custom is active $isActivefilter = $this->filter ->...
Ethan Yehuda's user avatar
1 vote
1 answer
144 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::...
MageRun's user avatar
  • 11