Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions related to Magento collections

0
votes
0answers
11 views

Magento 2: Parsing Item information through block

Good day, I want to create a phtml file and create a dynamic block with that one to put on CMS pages - Take it as product information blocks where i want to display the product name, the price, the ...
0
votes
3answers
40 views

How to prevent memory consumption during collection enumeration?

In the following script: $pageSize = 1000; $productCollection = Mage::getModel('catalog/product') ->getCollection() ->addWebsiteFilter($website->getId()) ->...
0
votes
1answer
20 views

Retrieve Compare Items Collection returning zero Items Magento 2

While I am trying to return compare items in custom module phtml file, it is returning zero items but in database table catalog_compare_item showing all the added items to compare. Class Used : ...
0
votes
1answer
14 views

Magento 2 Get product collection filter by atributes does not give the exact match

I have created a filter to get product bellow is an examples: $filter = array( array('attribute' => 'color', 'eq' => '2'),//id of option array('attribute' => 'size', 'eq' => '5'),// ...
0
votes
1answer
16 views

What is the role of visibility filter in colections Magento 2?

I am getting Order Items, from order collection by Order ID but as from the attached screen shot (Order 15) I am getting one product data two times. Can any body explain the reason and what will be ...
2
votes
0answers
16 views

Check if 2 dates already exist in collection filtering

i have a custom collection which has database column start_at and end_at in Y-m-d format , i try to do some validation before inserting to database, one of them is make sure the period between ...
0
votes
0answers
14 views

magento 1 custom report collection initselect issue

I created custom report module named Hs/Paymentreport and Collection file extends Mage_Sales_Model_Resource_Report_Collection_Abstract class. In my collection class file, __construct() method looks ...
1
vote
0answers
26 views

Magento 2 : how can i add my custom filter in custom admin grid

i have created custom admin grid which shows the log of login customer, every time customer login successfully the log will be added in that grid even if same customer, what i want to do is add my ...
1
vote
1answer
21 views

Alter getProduct collection

I need to alter the equivalent of native "getProductCollection", but I don't know how and where to do this. I need the getProductCollection to look like this : public function getProductCollection() ...
0
votes
1answer
27 views

Get all guest & customer email id's in single collection Magento 2

I am trying to list all unique email id's (guest & customers) in admin grid to restrict specific email id to place order. For that, I got an id's from customer collection and order collection. ...
2
votes
1answer
47 views

Magento 2.2.6: Product collection does not apply the filter

EDIT: I have seen that in magento 2 the ListProduct page is cached, for this reason once loaded it does not enter. Is there any way to modify the query returned by ListProduct? I extend the class: ...
0
votes
1answer
26 views

Magento 2 Join Product Collection with Custom CollectionFactory

In Magento 2.2.5, I have Custom Model Collection (followed this tutorial). In that I want to add the Product Collection into this custom collection by default. How to achieve this.
0
votes
1answer
24 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)...
1
vote
1answer
31 views

Duplicate entities in collection

I'm trying to extend Products in carts report grid. I needed to separate products for each customer and add a Customer name column. So for example a product with id number equal to 123 may exist in ...
1
vote
1answer
23 views

unable to solve the error in magento2

I need to solve this below error, Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught TypeError: Argument 1 passed to Webkul\Pos\Model\...
0
votes
0answers
13 views

How to get a Array Response from collection with getfieldset

I'm trying to get a Array Response from collection with getfieldset like below, still got this error and unable to resolve this. Uncaught Error: Cannot instantiate interface Magento\Framework\DB\...
2
votes
2answers
65 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 ...
1
vote
3answers
27 views

Error in collections

I had an error like below, Fatal error: Uncaught TypeError: Argument 5 passed to Webkul\Pos\Model\ResourceModel\Agent\Collection::__construct() must be an instance of Magento\Framework\App\...
3
votes
1answer
33 views

How to create a addnametoselect function for custom tables

I need to create an addnametoselect function (like in customer collection) for filtering purpose in the custom collection filter by the fields in custom Table on DB in magento2. Please, anyone, help ...
0
votes
0answers
15 views

Sort categories children by position

I want to sort categories children by position. What i mean: I have this code which gets categories collection and then puts those categoris in an array of items (items = category). $result = []; ...
1
vote
1answer
51 views

Magento 1 - Convert Object into an array value

I was trying to get the information of tracking in the UPS. I got on of the method from the core (app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php => method name getTracking($trackings)) that ...
2
votes
1answer
32 views

Magento 2: How to get Customer collection filter by Full name like admin grid?

How to get Customer collection filter by Full name or by keyword like admin grid of magento 2? Can Anyone help me? Thanks In advance.
0
votes
1answer
24 views

SKU Report for null attribute values

I am getting all product sku's that does not have a attribute value 'image_link'. I have written this code in magento : $products = Mage::getModel('catalog/product') ->getCollection() ->...
1
vote
0answers
21 views

How to get collection from database in phtml not from cache when full cache enabled

I have created an extension which I have uploaded in the marketplace but marketplace rejected due to cacheable="false". <block class="Company\Module\Block\Hello" name="information" template="...
2
votes
1answer
25 views

Group Collection to Filter Unique Products Based on a Specific Attribute

Scenario: A store catalog is populated with configurable products each having several children with different sizes and colors. As the goal is to show the different color variations, only the ...
0
votes
0answers
12 views

Display content between set products on magento 2 category page

I was wondering if there would be a solution to display blocks, with content i can enter in the backend, between or after a set amount of products. I know i can display some static content at the top ...
0
votes
1answer
18 views

Mysql FULL JOIN in magento 2

How can i execute something like full join in magento 2 then set query data in my collection. Below i try to do somethig. $joinLeftCustomerSql = $connection ->select() ->from("$...
0
votes
0answers
11 views

Magento 2 filter datetime which already pass 24 hour

I have created a custome model and this model has created_at attribute, i need to find the model collection which created_at is greater than now in 24 hour: for example : $transaction = $this->...
1
vote
1answer
16 views

Magento2 | MassAction Filter instance none given

I'm getting strange error when I want to use mass action in a grid : AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to Toto\\Helloworld\\Controller\\...
0
votes
0answers
19 views

Modify the existing product collection in magento 2

I need to modify the existing product collection in magento 2. Product name, description, image etc are loaded from the third party url and inventory & pricing details are from magento db itself. ...
0
votes
2answers
34 views

Call to undefined method addFieldToFilter() in magento 2

I have a model,resource model,collection file shown below. app/code/Magge/Custom/Model/Categrory.php namespace Magge\Custom\Model; use Magento\Framework\Model\AbstractModel; class Categrory ...
2
votes
1answer
40 views

how to retrieve Coupon Code by rule Id on Checkout Success Page?

I have coupon rule collection created at admin side and displaying rule names in the system configuration of the custom module. Actually, I wanted to get coupon code of a cart rule that has been ...
1
vote
0answers
18 views

override getLoadedProductCollection of \Magento\Catalog\Block\Product\ListProduct

I am overriding getLoadedProductCollection() in my block where performing some custom query public function getLoadedProductCollection() { $myCategory = $this->...
1
vote
1answer
78 views

Magento2: How to get product collection by attribute or category id?

How to get product collection by multiple attributes? Magento 2.0
0
votes
2answers
41 views

Magento2 how to modify admin grid collection using ui component

You guys would be knowing that usually, we are using core Magento DataProvider while creating admin grid using UI component. Sometimes, we need to add some filter or modify the basic grid collection ...
0
votes
1answer
38 views

Remove item from category collection in Magento 1.9

I have a category collection in Magento 1.9 This is my code :- $categories = Mage::getModel('catalog/category') ->getCollection() ->addAttributeToSelect('*') ->...
0
votes
0answers
11 views

Cache management on collection

I am creating a custom magento 2 module of a blog. I have a block : <?php namespace Formation\Blog\Block; class Posts extends \Magento\Framework\View\Element\Template { public function ...
0
votes
2answers
24 views

Array to string conversion while trying to get product collection

I'm trying to get a product collection. I got it by function: public function getProductCollection() { $collection = $this->productCollectionFactory->create(); $collection->...
1
vote
2answers
66 views

Filter customers by custom attribute in admin grid

I added custom attribute to customer and now I want to filter customers by that attribute in admin grid (admin->customers). I want to user see only customers which custom attribute has specific value. ...
1
vote
1answer
89 views

How to ignore not avilable products from best seller product collection?

app/code/Test/Demo/Block/Widget/Bestsellerdproduct.php namespace Test\Demo\Block\Widget; class Bestsellerdproduct extends \Magento\Framework\View\Element\Template implements \Magento\Widget\Block\...
1
vote
1answer
20 views

Magento 2: Get collection in specific order

I want to get collection in specific order (apart from ASC or DESC order). Here is my collection: $productCollection = $block->getProductCollection() ->create() ->addAttributeToSelect('...
0
votes
0answers
11 views

Repository collection join processor doesn't work when called twice

I have a repository that has to join a table for certain filters when using getList. I noticed that Magento does this using a JoinProcessor. Everything works fine except when calling getList a second ...
0
votes
0answers
74 views

Magento 2 : collection filter error : Exception #0 (RuntimeException): Illegal state

I am having problem with collection filter I am using event catalog_product_collection_apply_limitations_after to add collection limitations In the observer i am using below code to apply filter. ...
1
vote
2answers
19 views

Magento2 Multiples fileds for the AbstractModel

How can I add more than one field in the load method of the \Magento\Framework\Model\AbstractModel $consumptionCollection = $this->_consumptionFactory->create()->load($iccid, 'iccid'); I ...
0
votes
0answers
8 views

Join tables in collection

I have a collection of products filtered in layered navigation. $productCollection = Mage::getSingleton('catalog/layer') ->getProductCollection() ->addAttributeToSelect('*'); I ...
0
votes
0answers
20 views

what is feasible getCollection with product_id filter or load for getting attribute values in magento 2

I can get product-data (like an attribute) via the load() method, but I would like to do the same thing, only filtering the collection with product_id like addFieldToFilter() and using ...
2
votes
2answers
147 views

addAttributeToSelect Call to undefined method M2

I have two custom modules and am calling one collectionfactory in other module and getting ` Call to undefined method addAttributeToSelect Collection file look like class Collection extends \...
2
votes
2answers
74 views

load customer object update issue in magento 2?

I have used below code in my controller use Magento\Customer\Api\Data\CustomerInterfaceFactory; class editPost extends \Magento\Framework\App\Action\Action { protected $_customer; protected $...
4
votes
1answer
37 views

How to select image from categories collection?

I have entity \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection And I'm trying following $categoryCollection->addAttributeToSelect('image'); but this doesn't work ...
0
votes
0answers
18 views

AdminGrid get collection on tab click / load on demand

Greetings StackExchange. I have a feature request on a admingrid. We are using Boost My Shop ERP for our shop. Is it possible for make a modification on how/when to load the collection? The ...