Questions tagged [resource-model]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
25 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 ...
0
votes
0answers
13 views

How to override SimpleProductPrice Model the right way?

I want to override the function executeByDimensions for some reasons. Below is my implementation. <!-- Vendorname/Modulename/etc/di.xml --> <?xml version="1.0"?> <config xmlns:xsi="...
1
vote
2answers
47 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-...
0
votes
3answers
44 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-...
0
votes
0answers
22 views

How to join directory_country_region and directory_country_region_name tables in magento2?

I have created an admin grid. In resource model using a table name, directory_country_region and data display in grid columns. I have a created column locale. Locale filed in another table ...
0
votes
1answer
24 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($...
1
vote
2answers
53 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 ...
0
votes
2answers
29 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="...
0
votes
2answers
89 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?
0
votes
2answers
97 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 ...
1
vote
0answers
29 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\...
1
vote
1answer
39 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? ...
0
votes
0answers
25 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> ...
0
votes
1answer
78 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 ...
1
vote
1answer
112 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 ...
0
votes
1answer
31 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, ... ) { ...
2
votes
1answer
75 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\...
4
votes
0answers
56 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 ...
1
vote
1answer
95 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 ...
1
vote
1answer
47 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\...
1
vote
2answers
260 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; ...
0
votes
2answers
160 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 ...
0
votes
1answer
38 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.
2
votes
1answer
196 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' ...
1
vote
2answers
180 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 ...
1
vote
1answer
99 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->...
1
vote
1answer
33 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 ...
0
votes
1answer
251 views

invalid create method

I have a model, I call it in a block and when I use the create method I get an error saying: Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid method Vendor\Namespace\Model\...
0
votes
1answer
218 views

Check if product type is grouped, without loading whole product

I want to check whether a certain product is of type 'grouped' or something else. And, i need to do this without loading the whole product. Now for other attributes the code below seems to work ...
2
votes
3answers
250 views

magento 2 : model in custom module

i already have a table in database also created model files and all works fine so now added another table successfully so what changes i need to do with model files i mean in model resourcemodel and ...
2
votes
1answer
93 views

visibility attribute value is not rendering from product collection in magento 2

We need to display the visibility of the product in category page, but currently we are not able to fetch its value from product object. We tried with $_attributeLabel = $_product->getResource()-&...
0
votes
2answers
821 views

Call to undefined method addFieldToFilter() in magento 2

I have a model,resource model,collection file shown below. app/code/Magge/Custom/Model/Categrory.php namespace Magge\Custom\Model; use Magento\Framework\Model\AbstractModel; class Categrory ...
0
votes
1answer
81 views

Magento 2 assigning Custom User resources in User roles

When I am trying to create a new User role. After selecting the Custom resource List is Not showing, Can u Please help me how I can do this. I what to Create a login for Product Manager to Upload ...
1
vote
1answer
39 views

Module with cron job to fetch all products where custom attribute is true

I am brand new to Magento module development, and I need some help getting started. My goal is relatively simple: I'd like to create a module which fetches all products with a custom attribute '...
0
votes
1answer
70 views

Magento 2 getting Error override resource model

I have facing Below error when I override resource model Fatal error: Call to undefined method Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Interceptor::getAttributeId() ...
1
vote
1answer
486 views

Magento 2: How to override model resource configurable file

I have created a custom module. di.xml < type name="Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable"> < plugin name="ptgConfigurableProduct" type="...
3
votes
2answers
88 views

Magento 2.2.5: Add Student Instead of Update Student

So instead of update the student, this code add a new student. I'm looking for a way that not using object manager, because the objectmanager is recommended not to use. So when i searching for how to ...
4
votes
1answer
606 views

One to many relationship in M2

I am working on a module where I have to implement one to many relationship. I have one table for series with id and name field and one table series_product where I have id, series_id, product_id and ...
0
votes
2answers
543 views

Magento 2 : CRUD, Invalid method _getResource() in model when Save

Magento CE 2.2.0; I created CRUD for model 'people' and save data in to database by controller for testing. While i try to save by using controllor Add: $_person = $this->_objectManager->...
4
votes
1answer
597 views

How to use collection factory model in Unit Test magento 2

I have a custom extension with model with structure like this in database: +----------------------------------+ |entity_id | customer_id | balance | +----------------------------------+ | 1 | ...
0
votes
1answer
130 views

How to define where condition in resource model function for specific value? magento2

How to define condition in resource model function , i have a function for sales reporting , here it is fetching records from defined columns as given below , i want to add condition here for status ...
0
votes
2answers
118 views

Private method error while overriding Magento\Customer\Model\ResourceModel\CustomerRepository

I am using <preference> to override CustomerRepository, but Magento\Customer\Model\ResourceModel\CustomerRepository contains private functions and it throws me error Fatal error: Call to ...
0
votes
1answer
72 views

Getting Bool(False) on custom module when calling my model

I am not able to call my model each time it gives bool(False). table is creating in database from below code. to check my model i stored some data manually in table. I already tried Mage::getModel('...
2
votes
2answers
2k views

Magento 2 override the product collection(Magento\Catalog\Model\ResourceModel\Product\Collection.php)

We want to override the product collection model class(Magento\Catalog\Model\ResourceModel\Product\Collection.php) We flow the below process to override the addAttributeToSort method but not working. ...
0
votes
1answer
485 views

Left join order grid collection using observer method. Magento 1.9

I'm trying to add a grid to order listing table following this awesome blog which works if all code copied but I'm unable to customize it. And I want to show the data from my custom table. I've ...
1
vote
0answers
32 views

Associating two related models

So I'm creating a plugin wherein a customer can have grocery lists. I have two created models - GroceryList and GroceryListItem. A grocery list contains one or many grocery list items. I can fetch ...
0
votes
1answer
318 views

how to call getCollection method for a custom table on index controller?

$pincode = $this->getRequest()->getParam('p', false); $id = $this->getRequest()->getParam('id', false); $collection = $this->resultPageFactory->create(); $collection = $...
1
vote
1answer
326 views

How to stop saving resource model and throw error messages inside _beforeSave function?

I have the following codes inside a custom resourceModel class: protected function _beforeSave( AbstractModel $object ) { //My operations return parent::_beforeSave($object); } I added a ...
10
votes
1answer
3k views

What are the differences between a Model and a Resource model?

What are the differences between a Model and a Resource model? Also what is a model and a resource model?
1
vote
1answer
209 views

How to override resource models?

I wanted to overrid: vendor/magento/module-catalog/Model/ResourceModel/Product/Compare/Item/Collection.php so I copied it to: app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/...