Questions tagged [model]

Models contain most of the business logic in Magento modules

Filter by
Sorted by
Tagged with
0
votes
0answers
16 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
2answers
65 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\...
0
votes
0answers
17 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
0answers
24 views

Create a Model with a dynamic table Name

I have a Model/Repository & Collection in my Magento 2.4 custom module called Cars. It is linked to the db-table myapp_cars on my Multi-Site installation. Its a generic table with the following ...
0
votes
1answer
25 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 ...
0
votes
1answer
13 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
0answers
35 views

How can Magento 2 Vendor Model file override with custom module file

Magento 2 default paypal order after IPN completed turn to order status "Processing". This is the default order status I need to change paypal order IPN completed after order status "...
0
votes
1answer
43 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
2answers
21 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 ...
0
votes
1answer
19 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
0answers
35 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
1answer
21 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=&...
0
votes
0answers
42 views

How to add a custom form block inside order view?

I try to make an SMS form block for Magento2. Until now, I used the Magento\Sales\Block\Adminhtml\Order\View\History as a guide on how to implement it. I am almost there, but I cannot mimic the getUrl ...
0
votes
3answers
410 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 ...
0
votes
1answer
53 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
1answer
26 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\...
0
votes
1answer
20 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 ...
0
votes
1answer
33 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') ->...
0
votes
0answers
51 views

Magento is not generating factory classes

I am trying to create custom table in a plugin and trying to write model classes for it. Custom database tables is successfully generated. However I am struggling to let magento auto generate model ...
0
votes
1answer
36 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: /...
0
votes
0answers
24 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
0answers
16 views

How to use 2 models in layout folder in xml that should show in inside view show.phtml file. Please tell how the controller is linked with block

How to use 2 models in layout folder in xml that should show in inside view show.phtml file. Please tell how the controller is linked with block. And how a layout file is linked with the controller ...
0
votes
1answer
48 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\...
0
votes
0answers
23 views

How to create/add a personal model in module-customer in magento 2?

That model will be linked with the table rpt_customer_personal_info will call carry three fields like company, country, mobile. Please provide some help or give the links which can be helpful.
0
votes
1answer
13 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 ...
0
votes
2answers
289 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=&...
1
vote
1answer
30 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 ...
0
votes
1answer
55 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 ...
0
votes
0answers
19 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 ...
0
votes
0answers
89 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
1answer
282 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 ...
0
votes
1answer
24 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 ...
0
votes
2answers
223 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 ...
0
votes
3answers
780 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->...
0
votes
2answers
63 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/...
0
votes
0answers
41 views

Magento 2 Async WebAPI: Data in topic must be of type mixed. array given

I'm using magento v2.3.4 and created a Magento 2 rest webapi function like this: /** * POST for create brands api * @param mixed $data * @return array */ public function create($data); I usually ...
0
votes
1answer
66 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
1answer
23 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
vote
1answer
36 views

What is the fastest way to get 'is_active' column value from 'customer_entity" table?

I'd like to ask for the fastest way to get the column value of 'is_active' from 'customer_entity' table. It could be using object_manager or something. Thank you in advance
0
votes
1answer
34 views

Magento 2 - How to find out which data is available for an object?

I have a quote item: /** * @var \Magento\Quote\Model\QuoteFactory */ protected $_cartFactory; public function __construct( ... \Magento\Checkout\Model\CartFactory $cartFactory, ... ) { ...
0
votes
1answer
94 views

How to save custom table data in Magento 2?

I have created a table using a Controller and Model and in that file show some data. But i don't know how to save that data in database i have created a table in Magento 2 db. But don't understand how ...
0
votes
2answers
45 views

Issue in extending a model magento 2

I want to extend the Magento\ConfigurableProduct\Helper\Product\Options\Loader as per this github issue https://github.com/magento/magento2/issues/21663#issuecomment-477966963 My di.xml file is <?...
1
vote
1answer
81 views

How to get product from custom attribute in Magneto 2?

I have a Custom attribute on Product in which i have save a string i want to get count of those products which have same attribute value in Magento 2 using an Controller or Model.
0
votes
1answer
307 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\...
0
votes
1answer
25 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 ...
3
votes
2answers
284 views

What is difference between these models and design patterns used in Magento?

Yes, I know this question has many answers in google, but please clear my confusion. What is the difference between Repository and Factory, and when should We use a Repository vs a Factory in Magento ...
0
votes
1answer
612 views

I want to create column in sales_order table and view custom field on order edit section in magento 2.3.5

I am added one custom field in checkout address form and i want to store that field data in Database and also display this field in admin order edit page in magento 2.3.5, so anyone can have idea ...
0
votes
1answer
30 views

How to add created at and updated at column and update it on values save?

I want to add created_at and updated_at columns in a custom table and update both columns on saving the data.
0
votes
1answer
29 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 | ...
0
votes
2answers
120 views

Magento 2: Model Override not working

I want to modify the code of Magento\Sales\Model\Service\PaymentFailuresService.php. So I'm overriding Model file using the below code but it's not working. etc/di.xml <?xml version="1.0"?> &...

1
2 3 4 5
16