Questions tagged [factory]
Denotes questions related to Magento 2 factories.
32
questions with no upvoted or accepted answers
3
votes
0
answers
425
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\...
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;
...
2
votes
1
answer
218
views
How to override UpgradeData.php with Factory?
I need to override the UpgradeData Class from Catalog\Setup\UpgradeData
But the constructor has factories in his arguments like
CategorySetupFactory
When I run setup:di:compile I got an error that ...
2
votes
1
answer
384
views
Registering a shared service with a custom factory
I'm wondering how (if I can) register a shared service with a custom factory.
Consider the following code:
class MyApiFactory {
private $config;
public function ___construct(Config $config) ...
2
votes
0
answers
432
views
How to load facotry model load best practice?
class Product extends \Magento\Framework\View\Element\Template {
protected $_productloader;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
...
1
vote
0
answers
258
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 ...
1
vote
0
answers
276
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
...
1
vote
1
answer
603
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 ...
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 ...
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'...
1
vote
1
answer
266
views
Fetch a specific model in magento 2
I have 2 ways to fetch a model object:
$orderId = 18;
/** @var \Magento\Sales\Model\Order $firstOrder */
$firstOrder = $this->_orderFactory->create()->load( $orderId);
/** @var \Magento\...
1
vote
0
answers
247
views
Magento2 performance killer -factory pattern
Magento using factory pattern injecting non-injectable objects such as products,categories.so that it will create new object every time when you use create method on factory object.
Is there any other ...
1
vote
1
answer
1k
views
Why Magento 2.2.3 returns empty collection?
I don't have any prior experience in this. I want to fetch the products from Database. I am trying from past few hours.But not working.
I am using following code.
protected $...
0
votes
2
answers
193
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">
<...
0
votes
0
answers
105
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 ...
0
votes
3
answers
937
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-...
0
votes
1
answer
299
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();
$...
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.
...
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')...
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 ...
0
votes
0
answers
235
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 ...
0
votes
1
answer
433
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\...
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 ...
0
votes
0
answers
141
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 ...
0
votes
2
answers
216
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 ...
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\...
0
votes
1
answer
110
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)...
0
votes
1
answer
94
views
Magento 2.2.5: How to get something (students,teachers,products) by id
i'm doing update "students" on magento 2.2.5
and i'm stuck in how to get student data by id
i saw they use repository to load by id, but when i come in this file
C:\xampp\htdocs\magento\vendor\...
0
votes
2
answers
27
views
How do I add products to the page.phtml?
I have an array with the product ID in my block, how do I get the product list on the page like this:
0
votes
1
answer
844
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
){
$...
0
votes
0
answers
70
views
Creating a category programmatically using category factory, category data gets created in DB, but category is not visible in admin
Pretty much self-explanatory.
I create a category model using category factory and then use the ->save method to save the category. I can see some data created, along with catalog_category_entity, ...
0
votes
1
answer
48
views
PageFactory Error with Hello World, Interceptor.php
Working on the Hello World example here:
alanstorm.com/magento_2_mvvm_mvc
I'm on the "Passing off to the View" step but I get an error with the World.php file when I refresh the page as instructed:
...