2022 Developer Survey is open! Take survey.

Questions tagged [resource-model]

The tag has no usage guidance, but it has a tag wiki.

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

magento 2.4 create model for data not related to table

usually when we have a custom module with some data, it is pretty straight forward to create the models and all the backend ui components for listing and forms. My problem is that in my grid I want to ...
user avatar
  • 129
0 votes
1 answer
17 views

Magento2: How to add data in child table?

I have a custom module with named A and db tab is z ok. now question is my: How to add child table? which is already I have done with PK and FK key constrains. How to add data in created child table ...
user avatar
  • 120
0 votes
2 answers
34 views

Magento 2 applying filters to collection reflects in all phtml

I have applied a filter in a PHTML that loads in headers. The filter is below. In Constructor: \Magento\Catalog\Model\ResourceModel\Category\Collection $collection Block Code: public function ...
user avatar
  • 828
0 votes
0 answers
18 views

Magento 2 getting products use sql

I'm trying to get all products using Magento SQL. I just need to do some tweaks. If the product has a thumbnail, it should show its value and if it is null, it should show my custom text. My code ...
user avatar
  • 828
0 votes
1 answer
96 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()...
user avatar
0 votes
1 answer
24 views

Magento 2 admin order grid model filters based on conditions

I have overridden Magento's default order grid controller. I'm trying to apply different filters based on the custom cookie I set. My di.xml <?xml version="1.0"?> <config xmlns:xsi=&...
user avatar
  • 828
0 votes
1 answer
113 views

Url parameter in magento 2 collection filter

I need to filter Magento 2 custom grid model collection by URL parameter. I have used this below code. protected function _initSelect() { $objectManager = \Magento\Framework\App\...
user avatar
  • 828
0 votes
1 answer
77 views

Magento 2 call url param in Model Collection filter

I'm trying to get some data that matches the id in the URL. I have a param in admin URL like below. seller/items/index/id/9/ I'm using the admin UI component which is working fine. My model code ...
user avatar
  • 828
0 votes
1 answer
82 views

Create a ResourceModel based on 3rd Party API Call from Magento

I am working on integrating a 3rd Party API into Magento. I'd like to use an Admin Grid with a Data Source that comes from a 3rd party API. So Essentially the Flow work like this... User Loads into ...
user avatar
0 votes
1 answer
122 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 ...
user avatar
  • 17
0 votes
0 answers
37 views

How to modify data of Custom Field before rendering to backend form?

I have created a simple crud module that renders form with a few basic fields and saves data into database. Module is working fine and saving data correctly in the database. Issue is before rendering ...
user avatar
1 vote
1 answer
655 views

Magento 2 Category Tree With Multiselect and Text box in Custom Page

I am looking solution to get a Category tree on a custom page and parallel a text box, where the admin user could add some text and in parallel, he can select multiple categories. After adding text ...
user avatar
  • 2,717
0 votes
2 answers
541 views

Magento 2 - How to properly load quote model by quote id?

I used to load the quote like this: $quote = $this->quoteModel->load($quoteId); But now I get a warning in PhpStorm saying that this method is deprecated: Deprecated: 100.1.0 because entities ...
user avatar
  • 2,402
2 votes
1 answer
110 views

how to save data into custom table

i created 2 columns table. although entity_id is primary key but not auto_increment. entity_id is foreign key of quote table. db_schema.xml <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
user avatar
  • 29
0 votes
1 answer
390 views

Magento 2 how to insert data in custom table?

I'm getting an error everytime I send my form in order to store data in a custom table I created. This is the error: {"0":"M\u00e9todo no v\u00e1lido Transom\\Emall\\Model\\StoreOwner::...
user avatar
0 votes
1 answer
110 views

Magento 2 : How to restrct field to be update in model?

I have a field in admin from which only be change at the time of new record. On the form edit, I want to show that field as editable but don't want to save the changes. For that, I have created the ...
user avatar
  • 427
0 votes
1 answer
944 views

In Custom table always create a new row in magento 2?

I have created a custom table and update data using model and resource model. But it always create a new row on hitting ajax how to update row as old data is appear. I think i want to use Update query ...
user avatar
  • 526
0 votes
1 answer
60 views

Change database in Resource model

I split my database on 3 parts. In my env php is set default, but in one of my model i need to connect to table wich located in different db. How can i change target db?
user avatar
0 votes
1 answer
723 views

How to add Data to Custom table in database using model in magento 2.3.5

I am created one form for contact and i want to insert form data into custom table in database in magento 2.3.5 so can anyone have idea about it then please send me solution. <?php namespace Aspl\...
user avatar
  • 473
0 votes
1 answer
57 views

Cannot filter the data collection

I'm trying to filter the data collection from 4 hours to now and I have the below code but its not working. public function getWishlistProduct($wishlistid){ $to = date("Y-m-d h:i:s"); $from ...
user avatar
  • 480
0 votes
1 answer
117 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. * * @...
user avatar
0 votes
1 answer
44 views

How to properly use Model Collection in Magento 2

I'm using Magento 2.3.4 , and i kinda confuse with how to use Magento 2 model correctly or follow the code standard. I have a model collection with database structure like this: brand_id | name | ...
user avatar
  • 167
1 vote
1 answer
818 views

Magento 2 Save and Load functions

I just saw that Magento is going to deprecate load and save functions which we use in loading and saving models. Can someone provide some insights on this? What alternate we will be having now to use?...
user avatar
0 votes
2 answers
224 views

Magento2.3: How to collect the data by time?

I want to collect the records from 10PM to 5AM of wishlist data. I have already created a module and not sure how to filter the records by this timeframe. The wishlist table contains a field called ...
user avatar
  • 480
4 votes
1 answer
604 views

getCollection return null on custom model collection Magento 2.3.4

I'm creating a custom module to make a model by using mage2gen, I named this model critic: app/code/Vendor/Module/Model/Critic.php namespace Vendor\Module\Model; use Vendor\Module\Api\Data\...
user avatar
  • 167
0 votes
1 answer
220 views

Magento getData() vs getFieldName() in model

After load('id') function in model, we can get data by either model->getData('field_name') or model->getFieldName(). I know that both functions are provided by DataObject class but what I want ...
user avatar
  • 427
1 vote
3 answers
357 views

Magento 2.3 Unable to override Model: Magento\Reports\Model\ResourceModel\Report\Collection

Hello I am trying to override below function in below class using di.xml. Below is my code not working: di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
user avatar
0 votes
3 answers
440 views

Class *Factory does not exist when get data to show on frontend

I'm trying to get data from my custom table and show it to frontend. I followed to this tutorial: https://www.emiprotechnologies.com/technical_notes/magento-technical-notes-60/post/how-to-create-...
user avatar
  • 121
0 votes
1 answer
381 views

Magento2: How to check record before save record in table?

I am adding the barcode with product SKU and product ID in a table using below code:- File Path: /app/code/[NameSpace]/[ModuleName]/Model/ResourceModel/Custom.php public function generateBarcodes($...
user avatar
1 vote
2 answers
228 views

direct sql query in custom module

I have created a new web API module, this API should execute a direct SQL query. This is the code: namespace Mymodule\ProductByEbayItemid\Model\ProductByEbayItemidQuery; class ...
user avatar
  • 455
0 votes
2 answers
143 views

Resourcemodel plugin not working - Magento2

app/code/Mymodule/Orderedproductsreport/etc/di.xml <type name="Magento\Reports\Model\ResourceModel\Product\Sold\Collection"> <plugin disabled="false" name="...
user avatar
0 votes
2 answers
1k views

Magento 2 : Insert Records in Multiple Table

I have created 2 table : table_1 : id (Primary key) name status table_2 : sub_id (Primary key) id (Foreign key table_1 id) description How to save records in both table using single model file?
user avatar
0 votes
2 answers
495 views

Grid not displaying in admin - custom Resource Model

I have a custom resource model mapping to a table named soldiers_thewatcher_watch with a primary key: watch_id. I added the Grid UI component as well as a controller and admin link, but when I ...
user avatar
  • 188
1 vote
0 answers
34 views

Magento 2: join 2 table join issue

When 'm trying to join two tables in Magento 2, I get an empty result. This is the initial function that returns data from single table customer_entity without any error. \Block\Account\Message\...
user avatar
  • 115
1 vote
1 answer
131 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? ...
user avatar
  • 450
0 votes
0 answers
67 views

how to use other module data source to new module in magento 2

Hi I want to use the data source of module 1 to module 2 in Magento 2 how I can do this ?? vendor/module2/etc/module.xml <sequence> <module name=vendor_module1/> </sequence> ...
user avatar
  • 1,037
0 votes
1 answer
344 views

checking both updated_at and created_at filter with OR condition for product collection

Hello Please help me to updated this query to apply updated_at filter too with OR condition. Here If I want to add 'updated_at' too in the filter with the same condition like 'created_at' then what ...
user avatar
1 vote
1 answer
313 views

Magento 2.3. How to add data using model?

I have two variants adding data using Model. Which variant is more rignt ? Especially I want to ask about this $slider->setDataChanges(true);in first variant because I must set up _hasDataChanges ...
user avatar
0 votes
1 answer
35 views

Why magento2 outputs the query while showing data from ResourceModel collection Factory..?

protected $productCollectionFactory; public function __construct( ..... \Custom\MyModule\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory, ... ) { ...
user avatar
2 votes
1 answer
713 views

factory class duplicate insert check in magento2

I have created a model class as like below. Vendor\Module\Model/Bulider.php namespace Vendor\Module\Model; use Magento\Framework\Exception\QualificationException; class Builder extends \Magento\...
user avatar
  • 1,729
4 votes
0 answers
81 views

How to load Ui-component form data using another column instead of primary field Magento 2?

I have created a form using Ui-component it is working fine while adding new form & edit form. But I would like to do customization as per my requirement. Default Magento Ui form data is display ...
user avatar
  • 5,848
1 vote
1 answer
214 views

Recevied Empty array after using getItemsByColumnValue() collection method

I'm trying to retrieve a row from a custom table named 'lmap_shipping_tablerate' using a specific value for a column postcode. An empty array is returned when following line is used in my ...
user avatar
  • 493
1 vote
1 answer
54 views

Unable to display database table values on frontend in magento 2.1.7

I am trying to fetch table on frontend but getting this error Fatal error: Class 'Crud\Crudatfrontend\Model\ResourceModel\Post' not found in D:\xampp\htdocs\newmag\vendor\magento\framework\...
user avatar
2 votes
2 answers
695 views

How to update record using multiple conditions in CollectionFactory magento 2

I am trying to update the record but it creates a new record. Collection factory <?php namespace Webkul\Mpquotesystem\Block; use Webkul\Mpquotesystem\Model\ResourceModel\Quoteconversation; ...
user avatar
  • 1,037
0 votes
2 answers
533 views

Magento 2 : Custom Column Error

So, I have added a column to sales_order table. It is varchar type and it has some data in it. I found tutorial: here that show what I want to achieve exactly. Now, I am running Magento 2.2.3. and ...
user avatar
0 votes
1 answer
53 views

Model Collection.php magento 2

I cant seem to find any information why we need to create a Collection.php file inside ResourceModel and what is the purpose of collection.
user avatar
  • 493
2 votes
1 answer
421 views

Adding data to EAV attribute deprecated

I have an existing module with code like this: $attribute = $customerUpgrade->getEavConfig()->getAttribute(Customer::ENTITY, 'my_custom_attribute') ->addData([ 'attribute_set_id' ...
user avatar
  • 246
1 vote
2 answers
481 views

Magento 2 + How to import the custom city collection from the database into a dropdown (for the city textarea)

I'm a bit confused with creating a city dropdown with my custom cities. I have already imported the cities into a table and also created the Model, ResourceModel, Collection. Now I need to get those ...
user avatar
1 vote
1 answer
238 views

Implementing service contract Magento 2 deletebyid()

Implementing service contract using this method getting error of "Class string does not exist." model/userrepository.php public function deletebyid($del) { $hamburger = $this->...
user avatar
  • 1,321
1 vote
1 answer
57 views

Implementing service contract Magento 2? Getting error "Class Assign\RestService\Model\ResourceModel\Hamburger\CollectionFactory does not exist"

I am implementing simple service contracts. don't have much knowledge about service contracts following example from here How to implement service contract for a custom module in Magento 2? i am ...
user avatar
  • 1,321

1
2 3 4 5