Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [resource-model]

The tag has no usage guidance.

0
votes
2answers
57 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
34 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
28 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
33 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
39 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
30 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
40 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
96 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
166 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
48 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
207 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
28 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
15 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
50 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
161 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
79 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
364 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
296 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
312 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
90 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
59 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
35 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('...
1
vote
1answer
1k 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
252 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
31 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
201 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
153 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
2k 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
93 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/...
0
votes
3answers
591 views

Correct way to save entries to database

I want to know, what is the correct way to implement CRUD operations in Magento 2? because I found a lot of examples but they use deprecated methods. I created a table ('quote reserved item') with ...
0
votes
1answer
359 views

Get count from Resource Model Collection

I want to get the collection's count by using this method : public function getCount() { $connection = $this->getConnection(); $select = $connection->select(); $...
0
votes
0answers
14 views

Cannot display db table content in magento 2

This is my Controller/index.php <?php namespace Wallet\Payment\Controller\Index; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; use Wallet\Payment\Model\...
1
vote
1answer
33 views

ClassName::class vs FQN (eg '/Magento/Catalog/Model/Product')

In magento2's code style its mentioned to use ::class. see: http://devdocs.magento.com/guides/v2.0/coding-standards/code-standard-php.html however in objectManager or resource model initialization i ...
4
votes
3answers
3k views

Magento 2.2 error: Unable to unserialize value

After upgrade to the version 2.2 my modules which has serialized values does not work any more. Here is some info from the Magento 2.2 release notes: Significant enhancements in platform security ...
3
votes
0answers
241 views

Magento 2 : How to Return the Collection from afterload

I have implemented this jquerytokenizer in Ui Component form shown in the below image. It works well , the data is saved accurately- but when I go to edit a saved record this field is empty ...
0
votes
1answer
288 views

Factory create model is not empty Magento 2

I use a custom model with it's own Factory. In my helper in the construct public function __construct( \Company\Module\Model\ResourceModel\Communication\CollectionFactory $communicationFactory ){ $...
5
votes
2answers
4k views

Magento 2: What is a Resource Model and how can I use it?

In Magento 1, using a resource model we are getting collections of data: $products = Mage::getResourceModel('catalog/product_collection'); $category = Mage::getResourceModel('catalog/...
2
votes
2answers
421 views

Magento2 Override Resource Model does not Work

I am trying to override a resource model class Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\TierPrice to select new columns that I have created in the ...
5
votes
1answer
148 views

Missing core resource models?

If you have a model, normally there should be a resource model and a resource collection too, but there are some core models where this is not the case. Example: Mage_Log_Model_Customer I tried to ...
0
votes
1answer
929 views

How to call resource model function in controller in Mangeto 2

I have this resource model: <?php namespace namespace\module\Model\ResourceModel; class Post extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Date model * *...
1
vote
2answers
1k views

Magento 2: Delete data in custom module

I need to delete my custom table data, I tried below code, but its not works for me. my table: test_id product_id testing 1 15 12345 my code: try{ $model = $this->...
0
votes
1answer
579 views

Override abstract class Sender class in magento 2.1.4

I am trying to set runtime Email Invoice template base on custom rule in magento 2. So I am trying to override class below: Magento\Sales\Model\Order\Email\Sender But above class is abstract classs ...
4
votes
0answers
179 views

No ID parameter in model save controller when saving after edit

I've written a model object and I cannot edit and save an existing object, a new object is always created. I can create and delete, but editing doesn't work. I'm pretty sure that this is because the "...
0
votes
1answer
262 views

Correct way to join core tables in magento 2

I am able to join table something like this.. $totalsales = $this->orderCollectionFactory->create() ->addFieldToSelect('*') ->...
0
votes
1answer
923 views

Error class AbstractDb not found

I'm following this guide : http://www.mage-world.com/blog/how-to-use-model-and-collection-in-magento-2.html But at the end i get the error Fatal error: Class 'Magento\Framework\Model\Resource\...
1
vote
0answers
324 views

How to load a model with relationships via repository in Magento 2?

Background story: I was trying to load a model with model_store relationship using this snippet. I failed to do that with my own model. Model is being loaded without store data. Some debuging later I ...
0
votes
1answer
948 views

Magento 2 get custom module data in theme phtml

I have created the custom module and inserted all the required fields detail in the database. Now, I want to list all rows in below file path: I have tried with the $objectManager, but direct call $...
1
vote
1answer
218 views

Filtering a collection by product entity_id results in collection missing products

I'm having issues trying to create a collection of child / associated products given a particular parent / configurable product. I have no issue creating the collection for the parent (i.e. ...
1
vote
1answer
2k views

Magento 2 Get last and first item from model collections

I want to retrieve the last and first item from model collection in magento 2, in magento 1.9 i can simply retrieve it like this : $lastItem = $collections->getLastItem(); $firstItem = $...
3
votes
1answer
652 views

Resource Model vs Repository in Magento 2

I am quite confusing on the concept of Resource Model and Repository in Magento 2. Are they both responsible for managing the persistent storage, like MYSQL? Let says I would like to get specific ...