Questions tagged [model]

Models contain most of the business logic in Magento modules

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 views

Set function not working on Customer\Visitor model for custom column

I am trying to add new custom columns for now online customer grid. I have added new custom columns in customer_visitor table, but I am not able to save data in custom columns. Firstly, I have added ...
0 votes
0 answers
14 views

Magento 2: Error: Cannot instantiate abstract class Magento\Framework\Model\ResourceModel\AbstractResource

I'm using Magento 2.4 and getting the following error on order submit. I did run rm -rf generated/code/* generated/metadata/* pub/static/* var/cache/* var/composer_home/* var/page_cache/* var/...
1 vote
1 answer
13 views

is it possible to extend the block class in model

Is it possible to extend block class in model? if so, how to do it. please provide me with example. I have inherited model a class from model and i want to inherits class in block using the class i ...
  • 111
0 votes
2 answers
69 views

Magento 2: How to add new method in core interface?

I need to add new method to the core interface so I was checking all the Magento forums and came to know that this can be achieved via extension attributes as like in the post Magento 2 : Override ...
  • 490
0 votes
1 answer
60 views

how to create customer using custom rest api Magento 2.4.4

I have to create custom rest api for create customer programmatically in Magento-2.4.4. so anyone have an idea then share with me.
  • 507
0 votes
1 answer
26 views

Magento Javascript events

How does one discover which Javascript events exist in Magento 2? I need to run some Javascript code in an adminhtml form for a custom module. The code should run after the fields are displayed (i.e. ...
  • 1,166
0 votes
1 answer
32 views

Append "Add New" button in Grid Listing, on a Form

A custom module has Foo and Bar Models. In the Foo element's Form, there exists a grid listing of Bar items which belong to that Foo. This is an excerpt from the view/adminhtml/ui_component/...
  • 1,166
0 votes
1 answer
33 views

In Model Edit, display filtered grid of another Model

Consider two models, Foo and Bar. The Bar model has a non-nullable field foo_id which is associated with a Foo object. <?xml version="1.0" ?> <schema xmlns:xsi="..." xsi:...
  • 1,166
0 votes
1 answer
23 views

PASS DATA FROM MODEL TO BLOCK

Hello guys i get my data from db with API i want to show data in frontend , i can do this this is function, that return an array of data. public function getComputerAttr($customerId) { $...
  • 13
0 votes
0 answers
14 views

Customer Session Dont work adequately

i want to get customer id in model, but customer session return null in any case. Someone can help me ? I also try to get customer id in block but doest work !
  • 13
0 votes
0 answers
99 views

How to update table with model collection

I am trying to update the customer_entity table. But I am doing a left join with customer_address_entity. I want to update the group_id only when store_id matches my customer variable. Is this ...
  • 45
0 votes
1 answer
21 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 ...
0 votes
1 answer
75 views

Extending custom interface and data model

I have successfully created a custom interface. My model: app/code/Vendor/Samples/Model/Orders.php class Orders extends \Magento\Framework\Model\AbstractModel implements OrdersInterface { ...
0 votes
1 answer
26 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 ...
  • 118
0 votes
0 answers
15 views

Make model year module based on attributes not product finder type

I am searching for a module that all Me to search list of make base do modules and vice versa. Product finders generally have a predefined sequence.So you will have to first select make then only ...
0 votes
0 answers
253 views

Magento 2 GraphQL How to update custom row

Using Magento 2.4.3 Graphql Able to get, insert and delete a row from the custom table but unable to update(edit) custom row... custom endpoints - mutation { updateCustomMedia(id:7, input: { ...
  • 1,173
0 votes
1 answer
56 views

Magento 2 - Make fields in custom form required

I created a custom controller and model where users can save bank payment data information. I added a form where users can change data from the model. Is there a way to reuse the magento code to ...
  • 2,571
0 votes
1 answer
48 views

Magento 2 - store bank payment data

We have a debit payment method where the user has to enter some data like his name, IBAN, BIC and the name of the bank. I need to store these pieces of information in our database and automatically ...
  • 2,571
0 votes
1 answer
151 views

How to override Model file ConvertToCsv in custom module

Here am trying to override a vendor file that is vendor/magento/module-ui/Model/Export/ConvertToCsv.php etc/di.xml file <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
0 votes
0 answers
24 views

Payment Gateway sales_order Foreign Key Integrity Constraint Violation

I'm developing a payment gateway module and would like to persist some of the payment provider's return data to a custom table named xxx_yyy_transaction_log. The field order_id is a foreign key to the ...
1 vote
2 answers
437 views

Magento 2 : Custom Module Admin Grid is not Showing

My Custom module is working in Magento 2.4.0 but when I installed in Magento 2.4.3 version it's showing below error in grid section. Type Error occurred when creating object: Rh\CategoryGallery\Model\...
  • 1,366
0 votes
0 answers
24 views

Magento 2 : Model Without primary_key Possible?

Is it possible to create a Model without a primary_key? And if so, how? I'm trying to implement a backend model, which links different other models. My database table would look like this: link_id ...
0 votes
1 answer
179 views

Magento 2 - Delete from custom Model

I am trying to delete a record in my custom table (custom model). I can do it like this: $mymodel = $this->mycustomFactory->create(); $mymodel->load($id); $mymodel->delete(); But I ...
  • 486
0 votes
1 answer
67 views

How to override a method of a class where the method itself is defined in its parent class, and only called in the current class?

I would like to extend the OrderSender class, located at Magento\Sales\Model\Order\Email\Sender\ and then override the method prepareTemplate($order), this method is actually defined in the Sender ...
0 votes
1 answer
1k views

How to override a method in Magento 2

I would like to override a method of a class, but it does not work. The changes added to the method are not used. File \Magento\Sales\Model\Order\Email\Sender.php <?php /** * Copyright © Magento, ...
0 votes
2 answers
68 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 ...
  • 828
0 votes
1 answer
159 views

Custom Model not updating in catalog_product_save_after event

I ran into weird issue. I am trying to update my custom model/table in catalog_product_save_after event but it always creates new entry in the DB instead of updating older one. I'm doing this way : ...
0 votes
0 answers
150 views

Overriding model file of third party extension magento2.3.2: Type Error occurred when creating object

I am using amasty store locator extension. and I am customizing one of the model files of the extension.The file which i want to override is located inside Amasty/Storelocator/model/location.php. But ...
0 votes
1 answer
35 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=&...
  • 828
0 votes
3 answers
2k views

Magento 2: How to get last inserted custom table Id without saving new item?

I want to get the last inserted id to my block without adding new data into the table. I want to use this value to automatically filled in my phtml file. I tried getId and it's not working. I just ...
  • 15
0 votes
1 answer
420 views

How to pass current value of Ui form field in js file

I want to pass the value of checkbox in custom js file, I am using UI component to create a chechbox. So I have to pass this value to js file and then use that value in Model. I am not able to pass ...
0 votes
1 answer
178 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\...
  • 828
0 votes
1 answer
182 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 ...
  • 828
0 votes
1 answer
579 views

Get specific columns from Left Join

I am trying to join two tables like below $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $collection = $objectManager->get('Advance\Module\Model\Method') ->...
  • 828
0 votes
1 answer
126 views

Override Model from third party vendor in custom theme

I am trying to override a Model from a third Party vendor in a custom-theme. The original file was: /vendor/3rdpartyompany/3rdpartymodule/Model/Formatter/BaseImage.php I copied that file over to: /...
  • 413
0 votes
0 answers
61 views

Not able to add filters on getItemsCollection in admin order page

I am implementing a feature, where I need to filter the order item list in order admin page. I have checked and found the list is getting from method getItemsCollection(). But when I am trying to ...
0 votes
1 answer
207 views

Magento 2: Class instance

When i printed this print_r(get_class($this->getOrder())); I got this class name Magento\Sales\Model\Order\Interceptor What does this actually mean ? Where is this "Magento\Sales\Model\Order\...
  • 397
0 votes
1 answer
26 views

Need some brief difference about interfaces and model?

As we know save method by using modelfactory is deprecated i just want to know what is the alternative and how it is implemented because i tried API interfaces but at save i got stuck so kindly anyone ...
  • 1,351
0 votes
2 answers
916 views

Magento 2 :How to override Magento\Sales\Model\Order\Email\Sender.php model?

Is their any way we can override Magento\Sales\Model\Order\Email\Sender.php model in magento 2 module ? I have created below files di.xml <?xml version="1.0"?> <config xmlns:xsi=&...
  • 397
1 vote
1 answer
209 views

How to change model data via plugin

How to make a plugin for a model and turn one of its fields into a different value. For example, in the documentation, they make an after plugin for the model and return a different value. public ...
  • 138
0 votes
1 answer
151 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 ...
  • 17
0 votes
0 answers
23 views

Cannot Assign Param Value in Model Collection. Magento 2

I'm currently Facing a really strange Issue I'm applying filter on my custom table data in grid by adding function Vendor/Module/Model/ResourceModel/Withdrawal/Grid/Collection.php protected function ...
  • 1,436
0 votes
0 answers
227 views

How to get custom table from data fetch by form id in magento 2.3.1

How to get custom table form table by form_id for custom table in magento 2.3.1? try this but it's not working custom table screen short: Vendor\Module\Block\Form.php <?php namespace Vendor\...
1 vote
1 answer
836 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 ...
  • 2,767
0 votes
1 answer
37 views

Getting current page type in model?

Magento 2.3.4 Is it somehow possible to get the current page in a model? I am using some sort of page speed optimizer and want to disable some of its features on the product page. I checked the code ...
  • 255
0 votes
2 answers
777 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 ...
  • 2,571
0 votes
4 answers
2k views

Magento 2 - Check if record with certain value already exist in table before creating it

I created a new table company_shipping_quote. I am writing data into it like this: $quoteId = $quote->getId(); $html = $this->_generateNote($expressRule); $quoteModel = $this->...
  • 2,571
0 votes
2 answers
440 views

Magento 2 - Created new table and model - but model does not save!

I created a new table company_shipping_quote and new models by using https://mage2gen.com/. But how can I create a new object and save it so that it appears in the database? Models: Company/Shipping/...
  • 2,571
0 votes
1 answer
643 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::...
0 votes
1 answer
31 views

in magento controller file there is one get function is there "$mobile -> $model ->getphone();" where is that get phone method defined

in magento custom module controller file there is one get function is there for getting a phone number "$mobile -> $model ->getphone();" where is that get phone method defined.

1
2 3 4 5
16