A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
0
votes
1answer
20 views

Magento2: How to get Cart items collection on Product view page?

I want to get Cart items collection on product page. Help me.
2
votes
1answer
174 views

Sort collection by discount

I want to sort my collection by discount percentage for my sale category, I don't know if it is possible in Magento
1
vote
1answer
1k views

Magento 2.2 : Search Functionality/Layered Navigation on a Custom Product Collection?

I use a custom product collection which is used on all category view pages (basically, instead of using Magento's collection, I wrote my own module with the custom collection to implement a cookie-...
0
votes
0answers
9 views

Filter Layer Collection

I rewrite getProductCollection in /vendor/magento/module-catalog/Model/Layer/Search.php. How could i filter collection there. In filter i need remove all products with attributeSetId = $id &&...
0
votes
0answers
13 views

Magento2: How to create custom module category page with filter?

I have category listing page and I want to display product on same page. I want to display same layout like category page with filter. Please help.
1
vote
1answer
1k views

Magento2 how to override collection

I've just been working with Magento2 for 1 week. There are many things that made me confuse. I want to build a grid that show information from "directory_country_region" table but show only for "...
0
votes
0answers
16 views

Very slow Product collection load

I have a custom product collection that takes about 120 sec to load. How can I fix this? I'm posting the functions related to collection (not the whole module code): Mymodule/Block/Products/Category....
0
votes
1answer
26 views

Magento 2 Filter product collection by multiple attributes with OR

In Magento 2.3.3, How Can I Filter Product Collection by Multiple Attributes? First attribute SKU needs to check using "IN" second attribute is yes/no value. I need to filter collection by SKU array ...
2
votes
3answers
1k views

Magento 2: add fields to products collection

Ok so I'm trying to implement a simple export to CSV massaction on the Magento 2 Catalog products grid. I've successfully created the mass action item, as well as the admin controller. I am able to ...
2
votes
2answers
30 views

How to get rule id with respect to customer group id

class CouponCode extends \Magento\Framework\View\Element\Template { protected $_customerSession; protected $_customerGroupCollection; public function __construct( \Magento\Customer\Model\...
4
votes
4answers
16k views

addFieldToFilter() with OR Condition in magento2

$collectionData = $this->_productCollectionFactory->create()->addAttributeToSelect('*') ->addFieldToFilter(['attribute1', 'attribute2'], [ ['in' => $attribute1], ...
0
votes
1answer
691 views

load customer collection by email and mobile but not general group

I want to load customer collection by email and mobile but not general group for email load $customer = Mage::getModel("customer/customer")->loadByEmail($customerEmail); for mobile $customer ...
2
votes
1answer
584 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. ...
2
votes
3answers
750 views

Magento 2.3 Type Error occurred when creating object: Magecomp\Imageclean\Model\ResourceModel\Imageclean\Grid\Collection\Interceptor

I am using under given module. https://magecomp.com/magento-2-image-clean.html Till Magento 2.3.1 it's working perfectly. After upgrade to 2.3.2 it giving under given error: Type Error occurred ...
0
votes
2answers
1k views

Magento 2 : How to filter customer group collection?

Anybody have idea about how can i filter customer group pragmatically ? I can able to get customer group collection by using below code. $customerGroupsCollection = $objectManager->create('\...
1
vote
1answer
401 views

Magento 2 : Get Customer Collection with it's Attribute

I've managed to get customer collection using class \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory but it returns me default details not with Created Customer Attributes. Any ...
1
vote
2answers
4k views

how to get block data on phtml template in magento 2

what is missing in my code block data not shown in phtml template block page namespace xxxx\Trails\Block; use \Magento\Framework\View\Element\Template; use \Magento\Framework\View\Element\...
0
votes
0answers
14 views

How can i add a product per page dropdown in grouped product for child product list in admin

magento provides product per page feature for general products list in admin. and for gruped product list magento provides page switcher. but i want to add a dropdown in group product page like this....
1
vote
1answer
27 views

Magento2: What is difference between ProductFactory and CollectionFactory?

What is the difference between this below code? Class : \Magento\Catalog\Model\ProductFactory Code : $this->productFactory->create()->getCollection(); Class : \Magento\Catalog\...
1
vote
0answers
32 views

is there any way to display all my products in group product on one page in admin dashboard

Basically this is my group product and this is how we can see all of child products Now I dont want that previous and next button i just want all my products in list comes in one page or tab. help ...
0
votes
1answer
10 views

Generate a list in Magento Admin of customers that have a wishlist?

I need a way to get a list of customers that have a wishlist. Thanks in advanced.
1
vote
0answers
17 views

How to add several input fields per entry - admin form in Magento2? [closed]

I want to be able to edit one poll and it's answers in one admin form, and have one input field per answer. I already have my collections ready, how can I create a working admin form ? POLLS TABLE ...
3
votes
3answers
2k views

Magento 2 : setOrder not working in collection

In my custom collection $career_collection->setOrder('career_id','ASC'); not working. My function is below public function getAllCareers(){ $Careers = $this->_careersFactory->create(); ...
1
vote
2answers
29 views

How to remove collection filter from Magento 1.9?

I want to add filter to grid. When I add filter to sales_billing_agreement, I got the following error. SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'store_id' in where clause is ...
3
votes
1answer
96 views

How to get in stock product collection by category id in Magento 2.3.3?

I'm using Magento 2.3.3 with multiple websites store that uses different multiple stock sources(multi inventory) and I tried to retrieve product collection by category id like this: public function ...
1
vote
4answers
4k views

Magento 2: How to set visibility and status to product using collection?

I'm creating a cron to pass through all the products and set them visible and active. This is my execute of the cron who runs well: public function execute(){ /** * @var $item \Magento\...
7
votes
2answers
1k views

Magento2.2 getCollection from Factory deprecated

I get in my editor (PhPStorm) on getCollection the message that it is deprecated. In my controller i got the function public function __construct( Registry $registry, ...
5
votes
4answers
6k views

Get quote item collection by using quote item id in Magento 2

I get the quote_item_id like this: $orderItems = $order->getAllItems(); foreach($orderItems as $orderItem){ $qouteItemId = $orderItem->getQuoteItemId(); } I need to load quote item ...
2
votes
1answer
4k views

How to add collection filter to gridContainer in Magento 2?

I need to add a collection filter to my grid. I do few search on Internet but unfortunately it can't resolve my case. I'm using gridContainer instead of usual way. Here is my files: layout.xml <...
1
vote
0answers
26 views

Magento 2 - Category filter on custom search page

I have custom search page that is working perfectly and all the filters are applying properly except category filter. Following is the code: $indices = $this->searchResult->getIndices(); ...
0
votes
4answers
1k views

IN STOCK FILTER FOR Magento 2 Product collection

i am trying to filter inStock product in Magento 2 Using \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory, by $collection = $this->_collectionFactory->...
3
votes
1answer
44 views

Magento 2 - Multiple categories filter on product collection

I have a product collection $collection which is created by Magento\Catalog\Model\ResourceModel\Product\Collection code is: $collection = $objectManager->create('Magento\Catalog\Model\...
11
votes
4answers
13k views

To add default filter to grid in Magento2?

I have created one custom module with title & status field attribute in admin grid. Grid collections in module_test_grid_block.xml <arguments> <argument name="id" ...
5
votes
1answer
2k views

Grid pagination does not work in magento

Pagination is not working in my grid. All records are being shown on same page. All though Pagination is being shown at the top but all pages shows same records. Here is the code-- protected ...
1
vote
2answers
996 views

How to use addFieldToFilter & addFieldToSelect in magento2

I need to known how to use addFieldToFilter & addFieldToSelect in frontend.? And can i use like below, $searchQuery = $wholeData["searchQuery"] ?? ""; $searchQuery = trim($...
3
votes
2answers
1k views

Magento 2: Invalid customer attribute in collection filtering

I'm getting a strange error after filtering through customerFactory. Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid attribute name: is_active. private function ...
0
votes
1answer
17 views

How to filter with custom field on customer grid Magento 2

I have created a custom field in the filter on the customer grid using customer_listing.xml. Now, the issue is How can I filter with the custom field? Where do I need to do the operation? Please ...
0
votes
1answer
29 views

Filter collection by config product attribute value in magento 2 programmatically

I would like to know. How can i filter collection by attributes value as I am making filter api for app. Please check below code where i am filter the collection this is working for simple products ...
1
vote
0answers
13 views

Magento 2 Collection path wrong but still module is working and saving the data,how possible?

I am developing a custom module to save data in custom table. I have created model and resourcemodel classes and also collection.php <?php namespace Vendorname\Modulename\Model\ResourceModel\test;...
2
votes
1answer
38 views

How to shown all the category on home page in magento2

public function getShopCategories() { $objectManagerr = \Magento\Framework\App\ObjectManager::getInstance(); $categoryFactory = $objectManagerr->create('Magento\Catalog\Model\ResourceModel\...
0
votes
0answers
17 views

How to join directory_country_region and directory_country_region_name tables in magento2?

I have created an admin grid. In resource model using a table name, directory_country_region and data display in grid columns. I have a created column locale. Locale filed in another table ...
11
votes
5answers
55k views

Magento - Unable to set order of collection

This doesn't seem to be ordered correctly, anything I'm doing wrong? Suggestions? $componentQuantityCollection = Mage::getModel('catalog/product')->getCollection(); $componentQuantityCollection-&...
1
vote
0answers
19 views

Apply Magento\CatalogRule\Model\Rule\Condition\Combine to a collection FAST

I am using Karliuka m2.SmartCategory module for dynamic categories. This seems great to do what I need as was having issues with Smile modules virtual categories and this seemed to offer the same ...
2
votes
0answers
21 views

Magento 2 Join other tables using SearchCriteria JoinProcessor

Has anybody been able to join another table using SearchCriteria, JoinProcessor and virtual types. I have read the documentation (https://devdocs.magento.com/guides/v2.3/extension-dev-guide/searching-...
1
vote
2answers
54 views

How can I get my custom news collection on frontend in magento 1.9?

I had created a custom module for the news grid and form in Magento admin. I need to create custom pages with news collection on my custom news list page and a custom news detail page. How could I get ...
2
votes
2answers
131 views

Magento 2: How to setup layerd navigation in custom product collection?

I am trying to set a layered navigation filter on the custom cms page. for that, I have created a 1 cms page name test with two-column with left bar. and inside it, I have called one template file {...
0
votes
4answers
997 views

Magento 2, preference for Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection does not work

When filters + Ancor is enabled for category, sorting by product name doesn't work. I know the fix as I tested in Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection. So now I'm trying to ...
1
vote
2answers
2k views

Magento:2 How to Image upload in custom module

Image upload working fine in tmp folder, then store in DB. I want to after saving data image stored in the base folder pub/media/events var_dump($data); " ["events_url"]=> array(1) { [0]=> ...
2
votes
0answers
80 views

Tree categories from products collection

If I have a collection like this: $collection = Mage::getResourceModel('catalog/product') ->getCollection() ->addAttributeToFilter('my_custom_attribbute','my custom value'); What is the ...
1
vote
0answers
19 views

Magento 2 collection filter need advies

We have grouped products - rims. Now we want to sell it with tires. Logical is to look up for needed tires and show them, although the problem is if we do that we get results for front and back. but ...