Questions tagged [factory]

Denotes questions related to Magento 2 factories.

Filter by
Sorted by
Tagged with
1 vote
2 answers
201 views

REST API return JSON object using factory and interface

I am trying to create a simple module to return JSON data, if i returned string or array it will return the targeted data, but i can't return JSON object with key value when i return the interface it ...
Mohamad Zbib's user avatar
0 votes
2 answers
191 views

Why we need to add argument to plugin?

Recently I get through this below set of code and am not sure why the arguments are passed for the plugin. <type name="Magento\Framework\Mail\TransportInterfaceFactory"> <...
Ramesh KR's user avatar
  • 866
1 vote
0 answers
249 views

Wrong Price Rendering layout configuration. factory block is missed in magento2

Any ideas? main.CRITICAL: Wrong Price Rendering layout configuration. Factory block is missed {"exception":"[object] (RuntimeException(code: 0): Wrong Price Rendering layout ...
Andreja Vidovic's user avatar
0 votes
3 answers
231 views

Magento 2: existing products doesn't load regular price through a cron job

Everything was work fine. But now from cron doesn't load productFactory right! Can somebody please help me? public function __construct( Context $context, \Magento\Checkout\Model\Session $...
Andreja Vidovic's user avatar
0 votes
1 answer
31 views

Controller does not work

this is my controller <?php namespace Prevaj\Orderswatches\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { protected $_pageFactory; /** * Undocumented ...
pon aravind's user avatar
2 votes
1 answer
310 views

What does resultRedirectFactory?

I found a code at /vendor/magento/module-customer/Controller/Account/Login.php /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); I want to know ...
Vibhore Jain's user avatar
0 votes
1 answer
191 views

Diiference between Page Factory and Result Page Factory in Magento

What is the use of PageFactory and ResultPageFactory in Magento? Major difference between both and for what both are used for
Arun Sharma's user avatar
  • 1,305
0 votes
0 answers
104 views

The block is not displaying after loading the page

Please help solve this puzzle. I'm created after plugin, after load category widget. The collection of items must be used in the js. The idea is to simply intercept the collection in the plugin, load ...
Dmitry Zar's user avatar
2 votes
1 answer
896 views

PostFactory does not exist in generated Interceptor in magento 2?

any solution for this bug [RuntimeException] Class Vendor\Company\Model\PostFactory does not exist in [Vendor\Company\Controller\Index\...
Jitendra prajapat's user avatar
1 vote
0 answers
270 views

Unit test 'non-existent' factory methods

Potentially same question has been asked but differently. You are testing something in isolation and assume no access to generated folder. Helper method class HelperClass extends AbstractHelper ...
Dominic Pixie's user avatar
0 votes
1 answer
663 views

Magento 2 How can i create a custom factory class for a class?

I want to initialize some data on factory->create() without passing in the create(["mydata" => 1]). What's the way to create MyFactoryClass with custom create() for MyClass in my ...
Milind Singh's user avatar
  • 1,584
0 votes
3 answers
678 views

Magento 2 - "Undefined constant 'Product\SizeChart\Helper\Data'" while using helper

If anyone have idea then please share with me. I am going to stuck in this error: Uncaught Error: Undefined constant 'Product\SizeChart\Helper\Data' in /opt/lampp/htdocs/M2/app/code/Product/SizeChart/...
Deep Shah's user avatar
  • 555
0 votes
1 answer
234 views

What's the advantage of factory classes?

I figured out that magento 2 uses a proxy class which then creates an instance of a class. I don't understand why this proxy class is used, whats the advantage of it? Why not just creating the ...
Black's user avatar
  • 3,280
0 votes
1 answer
1k views

What is Factories in magento 2?

What is Factory in Magento2? Why use this. I want to know more details about Factory. When we can use Factory.
noseney's user avatar
2 votes
1 answer
118 views

What PHP class executes the SQL to select models and collections from the database?

When I have a PHP model or collection of a Magento entity (such as a product or customer), what PHP class(es) is in charge of constructing and executing the SQL that selects that model or collection ...
Ben Rubin's user avatar
  • 549
0 votes
3 answers
929 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-...
Tomato's user avatar
  • 121
0 votes
1 answer
885 views

How can I get all quote which is active with customer ID

Is there anyway I could print out in a table in phtml the following: Entity_id , is_active and store Is it possible to get all active quote within a customer_id? I want to show this in a table I ...
Jack Brooks's user avatar
1 vote
1 answer
117 views

Undefine factory on custom module

I am using Sphinx Search Extension. it was working good on Magento 2.2.8 version. Now am upgrade my store on 2.3.2 it give error Undefined factory sphinx Anyone also face this issue? if then how ...
HaFiz Umer's user avatar
  • 1,661
0 votes
1 answer
189 views

Magento 2 - How can I write query in Magento

I have a SQL query that joins two tables. SELECT ot.name, org.name from ayakil_organization as org INNER JOIN ayakil_organization_type as ot ON org.type_id = ot.type_id ORDER BY ot.name ASC ...
Mujahidh's user avatar
  • 2,791
0 votes
1 answer
294 views

Magento 2 how to do a query on custom collection

SELECT time FROM my_timeslot_list WHERE date = "2019-11-12" GROUP BY time; How do I run this query on collection factory. This is the code $collection = $this->collectionFactory->create(); $...
Jack Brooks's user avatar
0 votes
2 answers
77 views

Magento 2 - Factory Related Question

I have created a custom module, in that I have created the interface. As I am learning magento, I have seen in demo videos that for ex:- This is my custom interface name AffiliateMemberInterface. ...
Soni5041's user avatar
  • 145
1 vote
1 answer
592 views

Magento 2 Repositories and Database Transactions

Almost every post I read states that I should be working on objects using Magento 2 repositories rather that instantiating objects using Magento 2 object factories. That's what I started to do, and ...
Mark H's user avatar
  • 53
0 votes
1 answer
629 views

Magento 2: Obtaining an order object by an increment id in a loop using repositories and SearchCriteriaBuilder

This is my first stack exchange question, so I apologise in advance if I've not asked it in the correct way. I've just begun the process of getting to grips with Magento 2 in preparation for a ...
Mark H's user avatar
  • 53
0 votes
1 answer
56 views

how to check an array with cart price rule ID magento 2

I am trying to get Cart_Price_Rule. public function test() { $ruleArray = $this->adventCollectionFactory->create()->getData(); $ruleArray = array_column($ruleArray,'promo_rule_id')...
jibin george's user avatar
0 votes
0 answers
95 views

Magento 2.2.6 - Invalid factory was registered for this instance type

I have transferred my Magento project to live server and just changed database connectivity credentials. No other change. and if I run any Magento command then I get the following error: While ...
Khushbu's user avatar
  • 825
0 votes
0 answers
234 views

Magento 2.2.7 - How to access custom attributes of the associated products of a grouped product on final_price.phtml

Sorry in advance if this is a silly question. I'm fairly new to backend development. I have a custom attribute that determines whether or not a price should be visible on the frontend. It works just ...
Amelia York's user avatar
0 votes
1 answer
423 views

Magento 2 What method should I use instead of deprecated getCollection when fetching data from custom database table?

I created a custom database table and now want to fetch data, but getCollection method is deprecated and I can't find any other method that suits my case. Here's the example of my code: use Magento\...
Violeta's user avatar
0 votes
0 answers
142 views

Count order with certain product

I need count the orders of a given customer only if the order contains a specific category, how to modify this to get what I want ? ex : if the order has a product from the category "watches", I want ...
Morgan Tartreau's user avatar
1 vote
0 answers
1k views

How to resolve Circular Dependency when one Helper class is depends on other Helper Class

Having one module named Override\Search in which two helper classes are there. 1. Override\Search\Helper\Data.php 2. Override\Search\Helper\Util.php Both helper are depends on each other, thus ...
Softec's user avatar
  • 2,065
0 votes
0 answers
139 views

Classes *Factory from generated/ directory isn't use and look for them in vendor directory. Magento2.3

I'm using Magento\Catalog\Model\CategoryFactory in my module and in unit tests. Unit tests doesn't pass because CategoryFactory doesn't exists. Class CategoryFactory exists in generated directory and ...
Michal's user avatar
  • 1
5 votes
2 answers
4k views

Magento 2: When should we use a ProductRepository, ProductFactory, Product model?

When should we use a ProductRepository, ProductFactory, Product model? vendor/magento/module-catalog/Model/Product.php vendor/magento/module-catalog/Model/ProductRepository.php generated/code/...
Dj3's user avatar
  • 101
0 votes
2 answers
213 views

Why does magento 2 use hard coded "Factory" class?

As I've checked in Magento 2.3.1 Sales module there is one hardcoded Factory file in below path: vendor/magento/module-sales/Model/ResourceModel/Order/CollectionFactory.php And in Cms module there ...
Dj3's user avatar
  • 101
0 votes
1 answer
73 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, ... ) { ...
Arshad Syed's user avatar
2 votes
1 answer
960 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\...
Jafar Pinjar's user avatar
  • 1,929
3 votes
3 answers
5k views

Magento2 Alternate of Method getCollection() which is deprecated

I have checked the similar post: Magento2.2 getCollection from Factory deprecated But I still don't find the answer of it. I am calling getCollection() function, and PHPStorm saying that this ...
Shoaib Munir's user avatar
  • 9,394
1 vote
1 answer
386 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 ...
PhantomS's user avatar
  • 503
2 votes
2 answers
1k 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; ...
prabhakaran7's user avatar
  • 1,077
2 votes
1 answer
1k views

Magento 2.3.1 Download an excel file with PHPSpreadsheet

Trying to create a download button for an Xlsx file. Using PHPSpreadsheet for this however when downloading the file it seems corrupted with a stack trace at the bottom of excel files: Stack trace: #...
harri's user avatar
  • 5,455
3 votes
0 answers
424 views

Magento 2.3 collection factory not exist

I use magento 2.3 and I can't see collectionFactory created in generated folder or inject to any class. ModelFactory can create normally. There are my code: Model file: <?php namespace Lights\...
the light's user avatar
  • 708
2 votes
1 answer
4k views

Magento 2 :Get country code from Country Name

I have the country name with me. How can I get corresponding country code from it. For ex: If the country name is Unites States, I want to get country code from it ie, US If there any way for it? I ...
Vindhuja's user avatar
  • 1,395
1 vote
1 answer
12k views

What is Factory in Magento2 and Why use? [duplicate]

What is Factory in Magento2? Why use this. I want to know more details about Factory. When we can use Factory.
Chandra Kumar's user avatar
0 votes
1 answer
8k views

Facing this issue, It contains 1 abstract method and must therefore be declared abstract or implement the remaining method

Facing fatal error given as below. Fatal error: Class Sugarcode\Test\Model\Total\Fee contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Magento\...
jhon jhon doe's user avatar
0 votes
1 answer
109 views

RewardspointsFactory class does not exist

Please anyone review my code. Facing this error. Exception #0 (ReflectionException): Class Sugarcode\Test\Model\ResourceModel\Test\RewardspointsFactory does not exist Exception #1 (ReflectionException)...
jhon jhon doe's user avatar
1 vote
1 answer
136 views

GridFactory getting generated into wrong location

I have a custom module with backend management. I have an observer on config save that uses the file upload to read submitted file to update the collection however this fails due to below; class \My\...
BENN1TH's user avatar
  • 814
1 vote
1 answer
159 views

Magento 2: How to see the exact error

There are two parts to this question. 1. How can we add data to the database using factory not through object manager? 2. How can we find exactly what is the error in the code (dev mode is active, ...
Flutterer's user avatar
  • 728
2 votes
2 answers
506 views

Magento 2 Get Product ViewCount Value By Factory

Trying to get most viewed product view count value, I need to use it in another method calculations. E.g.(if most viewed product view count value is 100 then I need this value to be returned) What am ...
Trenox's user avatar
  • 397
9 votes
5 answers
9k views

What is the use of pagefactory in Magento 2?

Although I refer some blog of pagefactory, I don't understand the use of page factory. There is one code in the controller. Could you please explain to me how it works? public function execute() { ...
Bhakti Thakkar's user avatar
0 votes
1 answer
294 views

Magento 2.2.2 - Class not found in Factory

Namespace/Modulename/Model/WebService/ClientFactory.php <?php namespace Namespace\Modulename\Model\WebService; use Magento\Framework\ObjectManagerInterface; use Namespace\Modulename\Model\...
Slimshadddyyy's user avatar
0 votes
2 answers
2k views

Magento2 Model not loading complete data using Factory

Below is my construct function of controller - public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Vendor\...
Gagan's user avatar
  • 1,478
1 vote
0 answers
69 views

productCollectionFactory load function gives data in query but not in object

I have created a collection factory $collection = $this->_productCollectionFactory->create() ->addAttributeToFilter('status', '1') ->addAttributeToFilter('featured'...
Aditya Shah's user avatar
  • 7,597