2022 Developer Survey is open! Take survey.

Questions tagged [model]

Models contain most of the business logic in Magento modules

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 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 !
user avatar
  • 1
0 votes
0 answers
19 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 ...
user avatar
  • 45
0 votes
1 answer
19 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 ...
user avatar
0 votes
1 answer
15 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 { ...
user avatar
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
0 answers
14 views

Using Magento Events declared by AbstractModel _beforeSave When saving using Repository

i have created my Custom Entity name FAQ Created a Model and set $_eventRefix = "faq" in Model I am using Repository to save data which is working fine Now I want to call faq_save_after ...
user avatar
  • 2,029
0 votes
0 answers
9 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 ...
user avatar
0 votes
0 answers
102 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: { ...
user avatar
  • 1,123
0 votes
1 answer
13 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 ...
user avatar
  • 2,402
0 votes
1 answer
23 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 ...
user avatar
  • 2,402
0 votes
1 answer
60 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:...
user avatar
0 votes
0 answers
20 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 ...
user avatar
1 vote
2 answers
204 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\...
user avatar
  • 1,366
0 votes
0 answers
22 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 ...
user avatar
0 votes
0 answers
35 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 ...
user avatar
0 votes
1 answer
44 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 ...
user avatar
  • 464
0 votes
1 answer
31 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 ...
user avatar
0 votes
0 answers
65 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 "...
user avatar
0 votes
1 answer
315 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, ...
user avatar
0 votes
2 answers
35 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
1 answer
55 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 : ...
user avatar
0 votes
0 answers
105 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 ...
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
0 answers
55 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 ...
user avatar
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 ...
user avatar
  • 5
0 votes
1 answer
236 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 ...
user avatar
0 votes
1 answer
114 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
78 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
280 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') ->...
user avatar
  • 828
0 votes
1 answer
71 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: /...
user avatar
  • 383
0 votes
0 answers
40 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 ...
user avatar
0 votes
1 answer
114 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\...
user avatar
  • 367
0 votes
1 answer
14 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 ...
user avatar
  • 1,321
0 votes
2 answers
677 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=&...
user avatar
  • 367
1 vote
1 answer
75 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 ...
user avatar
  • 138
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
22 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 ...
user avatar
  • 1,434
0 votes
0 answers
175 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\...
user avatar
1 vote
1 answer
657 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
1 answer
29 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 ...
user avatar
  • 255
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
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->...
user avatar
  • 2,402
0 votes
2 answers
254 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/...
user avatar
  • 2,402
0 votes
1 answer
391 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
26 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.
user avatar
1 vote
1 answer
50 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
user avatar
  • 147
0 votes
1 answer
80 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, ... ) { ...
user avatar
  • 2,402
0 votes
1 answer
203 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 ...
user avatar
  • 526
0 votes
2 answers
71 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 <?...
user avatar
  • 828
1 vote
1 answer
133 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.
user avatar
  • 526

1
2 3 4 5
16