Questions tagged [repository]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
26 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. ...
0
votes
0answers
34 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 ...
0
votes
1answer
9 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 ...
0
votes
1answer
18 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":{ ...
0
votes
0answers
19 views

EAV Extension attributes vs repository

What is the point of Extension attributes? As documentation says "They are used to extend functionality and often use more complex data types than custom attributes". Magento provides nice way to use ...
0
votes
2answers
153 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://...
0
votes
0answers
36 views

Repository getList method and CollectionProcessor

I am working in Magento 2.3 and struggling with the implementation of the getList() method, specifically with the collectionProcessor. I have read devdocs (https://devdocs.magento.com/guides/v2.3/...
0
votes
1answer
33 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-&...
2
votes
1answer
25 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 ...
0
votes
3answers
107 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.
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 ->...
2
votes
0answers
17 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/...
0
votes
0answers
28 views

How can I get data from table using repositories? | Magento 2.x

How can I create repository in magento 2 and than get data from me custom table using this repository? Model of this tables is created.
1
vote
1answer
25 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\...
0
votes
0answers
14 views

How to filter with or condition on filter group?

For example queryterm='keyterm1 keyterm2 keyterm3'; (((p v q)^ ( r v s) ^ (t v u)) v ( m v n) )^ (k) p => sku like '%keyterm1%' q => name like '%keyterm1%' r => sku like '%...
0
votes
0answers
9 views

Reusing repository in same script not giving new results

I have a custom repository that sends off information to an ERP API. In a console script I am accessing this repository that pulls data from a custom database table. The rough outline looks like ...
1
vote
1answer
53 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? ...
1
vote
1answer
186 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 ...
4
votes
2answers
1k 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/...
0
votes
2answers
36 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\...
3
votes
2answers
375 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::...
0
votes
1answer
197 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/...
2
votes
0answers
20 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->...
3
votes
0answers
149 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": { "...
0
votes
1answer
157 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 ...
1
vote
0answers
238 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 ...
1
vote
0answers
50 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: ...
1
vote
1answer
40 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 ...
5
votes
0answers
76 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 ...
1
vote
1answer
106 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 ...
1
vote
0answers
22 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 ...
1
vote
0answers
30 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/...
1
vote
1answer
40 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 ...
2
votes
1answer
607 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->...
0
votes
0answers
67 views

Deleting Product gives StateException (code:0)

The codes: public function __construct ( ProductInterfaceFactory $product_factory, ProductRepositoryInterface $product_repository, Registry ...
0
votes
1answer
3k views

SearchCriteriaBuilder->addFilters() using multiple filters

As per title. This what I've done: $filterCode = new Filter(); $filterCode->setField('SpecialCode') ->setValue('') ->setConditionType('null'); $filterItemId = ...
2
votes
1answer
2k 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 ->...
1
vote
1answer
59 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::...
4
votes
0answers
106 views

How to handle multiple tables with magento 2 repositories?

As we all know, magento 2 suggests using repositories as an additional layer between resource models/collections and the rest of application. It's all pretty straightforward and simple when you use it ...
0
votes
1answer
563 views

Saved custom model doesn't returns it's id

I have a table with only 2 fields: id (primary key) and name. I've created a model for it, repository model. In my repository model, there is a method save. I'm trying to create a new record in my ...
3
votes
2answers
220 views

The difference in use Repository or RepositoryInterface to load model

I found two ways to load model on net by service contracts in Magento 2. One is use the Repository, another is using the RepositoryInterface directly. Both work well. What is the difference between ...
2
votes
1answer
1k views

Warning: Illegal offset type in vendor/magento/module-catalog/Model/CategoryRepository.php on line 133

I am getting Warning: Illegal offset type in vendor/magento/module-catalog/Model/CategoryRepository.php on line 133 on product details page in Magento 2.1.8 Which is caused by vendor/...
0
votes
1answer
498 views

magento sampledata:remove not working

I want to remove sample data or reinstall magento 2.2.1 without sample data i tried below command. php bin/magento sampledata:remove command is not working and throwing below error [Composer\...
0
votes
1answer
1k views

In Repository, how to replace deprecated load() function?

I know we should use service contracts(Repository) over $model->load(), but in Repository itself, how to replace the deprecated load() function? For example, in Magento\Cms\Model\PageRepository, ...
3
votes
0answers
278 views

2.2 Pipeline deployment

I was reading on the new Pipeline deployment here but I don't understand how this is supposed to work in a repository. In developer mode static content is dynamic, but if the build system commits ...
1
vote
0answers
710 views

How to manage custom attributes in group customer

i'm new in the magento world (and php community). I want to add some attributes to custom group in magento 2.2 I've created a new attribute by setup (his name is : 'exchange_id') : use Magento\...
1
vote
1answer
327 views

productRepository->getCustomAttribute('attribute_code');

I need to retrieve 1 product attribute value from 1 product, I wonder if using the product repository in this way is the most effective in terms of performances: $productColour = $this->...
1
vote
1answer
92 views

How do I connect a Magento database and a cloned repository on my local machine?

I am working with a magento 2 build via a repository clone. I have the dumped sql database from the repository build. I imported the sql into my localhost DB, how do I connect them so that a local ...
2
votes
0answers
524 views

Magento2 Compile command ends at Repositories code generation 1/7

Magento v2.1.7 CE PHP 7.0 Permissions double checked When I run compile command through cli, it ends at step 2 as seen in the image below. I found that it might be due to a wrong auth.json in ...
1
vote
2answers
3k views

How can I check if a product exists in Magento 2 without throwing \Magento\Framework\Exception\NoSuchEntityException?

I'm attempting to scan an incoming list of products and add any new ones to the catalog. Therefore, I must run a check on each product to see if it already exists. I'm using a ...