Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
2
votes
0answers
21 views

Get all associated categories from product collection

For a custom filter on the product collection i need to be able to get all associated categories from all products from the catalog search result. On top of that, i do not need the actual categories ...
0
votes
0answers
6 views

Mage 2.3: Create a new dropdown field in admin side custom module and its options should come from another custom module's table?

i have two modules and one gets a drop down on the admin side populated by the other values. The problem i am having is the collectionfactory is causing an error. Warning: Declaration of vendor\...
0
votes
1answer
13 views

Loading collection of products from a Category with admin filters

I am currently working on a project where it loads a collection of products with a CategoryFilter. $category = $this->categoryFactory->create()->load($categoryId); $collection = $this-&...
0
votes
0answers
16 views

Sorting products based on a custom attribute Magento2

I have a plugin that adds some custom product sorting, based on a customer attribute, in a way similar to below. # Vendor\ModuleName\Plugin\Product\ProductList\Toolbar; case 'capacity_low_to_high': ...
0
votes
1answer
26 views

In Magento 2 how can I return a collection without the top 10% and bottom 10%?

I am looking to return a subset of reviews for example but discard the top x% and bottom x% I could do it with an SQL query such as SELECT * FROM ( SELECT review_date, review_score, @r:= @r + 1 ...
0
votes
0answers
18 views

Filter on Collection is not working after left join in Magento 2

I am trying to join the customer collection with custom table. Below is mine code. $customerCollection = $this->_customerFactory->create()->getCollection(); $connection = $this->...
0
votes
1answer
28 views

Magento 2: load disabled category childrens

I need to get all category children of a specific category but disabled categories too. I have this category tree: + Root (ID: 2) // enabled | + Main 1 (ID: 3) // enabled | | + Sub 1 (ID: 4) // ...
0
votes
0answers
13 views

How to filter with or condition on filter group?

For example queryterm='keyterm1 keyterm2 keyterm3'; (((p v q)^ ( r v s) ^ (t v u)) v ( m v n) )^ (k) p => sku like '%keyterm1%' q => name like '%keyterm1%' r => sku like '%...
2
votes
0answers
30 views

How to filter collection for json data field in magento2?

Have any function or way we can directly filter json data in magento2? like: brand: {"product":"test","purchase":"500"} if i want to filter more than purchased 500 times in magento2 have any easy ...
1
vote
1answer
26 views

How can I remove orders from an order collection in Magento 2? Or how to generally remove items from any collection?

I'm using this code in a block to get a collection of orders in Magento 2: $orders = $this->orderCollectionFactory->create() ->addFieldToSelect('*') ->...
0
votes
1answer
24 views

Magento 2 :Product Filter in magento 2

Please suggest any free module which can provide the filter in the product listing page like the below screenshot.
0
votes
0answers
8 views

How to filter collection and still keep the original collection in Magento 1

I've created a custom module that allows you to add custom labels on product page. So I have a collection of custom objects and I want to filter it but I want to keep the original collection too. ...
2
votes
1answer
57 views

Magento 2 Class of custom module Collection does not exist

I created a basic index controller that outputs the collection but for some reason I am getting the following error: { "0": "Class Debug\\Tool\\Model\\ResourceModel\\LoadModel\\Collection ...
1
vote
1answer
45 views

how to filter magento 2 collection with 'or', 'and' combination?

For example, the search query is 'samsung lcd'. it can match with product name or SKU. I have below product names. 1.samsung xyz lcd. 2.samsung lcd pack. 3.samsung mobile 4.screen lcd. so when I ...
1
vote
0answers
16 views

Mage GetResourceModel in specific language in magento 1.9

I am working on a module to pull inventory data into a feed. For this we use Mage::getResourceModel. Pulling the data works alright, I just have the problem that the language changes depending on the ...
0
votes
1answer
14 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
1answer
36 views

Magento 2: Ui Component - Magento\Customer\Model\Session can't return current customer

I've got an issue using ui component on front in a large module. The model I'm using for my grid is used at several other points. But I discovered my configuration in di.xml is doing some strange ...
0
votes
1answer
105 views

Magento 2 Custom Product Collection Size Problem after Removing Products from Collection

In Category list view I want to create a custom collection where some products are not shown OR the entire collection is re-sorted. To test this I created an observer for the event ...
0
votes
0answers
24 views

SetOrder and Filter of a Collection

I'm trying to Sort and filter the getReviewsCollection in the Magento_Review/templates/product/view/list.phtml <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for ...
0
votes
1answer
21 views

Magento 2 Reset Modify FROM select query

How can one modify the FROM in select query without losing the left joins innerJoin etc... ? as I have tried: $collection->getSelect()->reset(\Zend_Db_Select::FROM)->from('table_2') but then ...
0
votes
0answers
13 views

Magento 2 : Join customer collection with custom collection

\Block\Account\Message\Message.php public function getAffiliateCustomerCollection() { $customerId = $this->customerSession->getCustomer()->getId(); $...
0
votes
2answers
27 views

Product collection retrieval N at a time (paginated)

I want to retrieve all the products. But would like to limit it to say 100 at a time to avoid too much memory usage. I have the collection factory injected in the constructor as \Magento\Catalog\...
0
votes
1answer
36 views

Magento 2: sort values in collection with unique flag

I have an array as collection and ordered it in ascending order with respect to expiry date as below: $creditDetails = $this->_creditFactory->create()->addFieldToFilter('customer_id', 1)->...
0
votes
1answer
38 views

Magento2 How to get current compare product collection on product list and product detail page?

I am using Magento2.3.1 and I need to list and detail page current product if add compare product than getting list and count on list and detail page. So I try to detail and list page checkbox with ...
0
votes
1answer
22 views

Magento 2: Display out of stock items in the end in API

I am using a headless magento 2 approach for my store. I have made an API which accepts parameters like: category_slug, sort_by, sort_order, page_size, current_page and returns the products ...
0
votes
0answers
31 views

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.attribute_set_id'

I am trying to Filter the products based on vendorid with attribute_set_id. if i use print_r in the collection i am getting the result like below $objectManager = \Magento\Framework\App\...
0
votes
2answers
44 views

Error in collection record update Magento 2

I have a custom collection I wanted to update a record. I want to do this as below: foreach ($creditDetails as $Card) { echo $Card->getRedeemAmount(); $Card->setRedeemAmount(...
0
votes
1answer
66 views

Type Error occurred when creating Interceptor after Updating to 2.3.2

After updating Magento from 2.1.6 to 2.3.2 and PHP from 5.6.30 to 7.2.20, now running into errors on page load. Have a module called Inquiry, which consists of forms to request things, and there is a ...
0
votes
1answer
29 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
3answers
66 views

converting Data Object to Magento 2 collection not working

I have a function defined in Magento 1 public function getStatusMappingCollection() { if (is_null($this->_statusCollection)) { $this->_plentyStatusCollection = new ...
1
vote
2answers
40 views

How to output and filter collection using “->where” filter?

I trying to get output from collection using 'where' filter but no result. This is my code: $collection = Mage::getModel('my_work/datanews') ->getCollection() ->...
1
vote
1answer
27 views

get customer who have not placed order from last 3 months but in optimized way

I need to optimized my answer. $start=2019-05-18 00:00:01; $end=2019-05-18 23:59:59; $customerArr=array(); $customers = Mage::getModel('customer/customer')->getCollection() ->...
1
vote
0answers
48 views

Function removeAttributeSearch

I have a code: $productCollectionClone = $productCollection->getCollectionClone(); $collection = $productCollectionClone->removeAttributeSearch($attribute->getAttributeCode()); Anyone can ...
0
votes
1answer
24 views

Magento 2 Product collection AddAttributeToFilter with AND/OR and !findinset and is null

How can i add " AND (at_product_userclass.value IS NULL) OR !FIND_IN_SET('1', at_product_userclass.value)" filter condition using addAttributeToFilter in product collection. Thanks
0
votes
0answers
17 views

Magento 2 - Collection Object filtered conditions values

I have filtred magento 2 product collection by different condition. Now , i need values of that options by which i have had filtered that collection. Any help appreciated. Urgent
1
vote
0answers
68 views

Add condition rule to collection product in Magento 2

I want to add condition rule in the collection product. How to do that. Hope someone help me.[![ public function getLoadedProductCollection() { $this->_limit = (int) $this->getWidgetCfg(...
0
votes
0answers
33 views

filter product follow condition magento 2

public function getLoadedProductCollection() { $this->_limit = (int) $this->getWidgetCfg('limit'); $type = $this->getTypeFilter(); $fn = 'get' . ...
0
votes
0answers
15 views

Magento 2 : Search pages not showing filter selected option

I have a amasty layer navigation extension. This plugin filter is working fine for all pages but one page have a issue. - search pages filter selected option not display. How can I solve this problem ...
1
vote
2answers
243 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
35 views

Get Categories collection in Helper file give 'Mage' not found error

I am trying to get categories in helper file I am using Mage::() to get categories in my helper file but it is throwing error. Here is the code to my helper file. <?php namespace Pulsestorm\...
0
votes
0answers
22 views

Magento 2 custom module select query doesn't work

I have the following query: SELECT `main_table`.*, `secondTable`.* FROM `table_one` AS `main_table` LEFT JOIN `table_two` AS `secondTable` ON main_table.blog_id = secondTable.blog_id WHERE (...
3
votes
1answer
58 views

Magento 2: How to load data by Page using same collection object again?

I am using \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory and loading data by creating objects. $collection = $this->collectionFactory->create() ->...
0
votes
0answers
16 views

magento 2 how to add search box to fronted for a custom table contents

How to add a frontend search box for a custom table contents. When the user enters three letters of a name then get data in pop up. Anyone Can help? Thank you in advance.
1
vote
0answers
27 views

How i can work with extension attributes using collection?

Hello i have to add extension attributes to Magento\Catalog\Api\Data\ProductInterface So i added this one to extension_attrributes.xml: <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
2
votes
3answers
140 views

Magento2 Need to filter grid when value is entered in search box, the column of the data is from another table

I have added 4 columns in the grid as displayed in below screenshot. For displaying for eg. Recipient Email column I added following code in XML & it's renderer PHP file. (Code is added below) ...
0
votes
1answer
34 views

Magento 2: How to filter orders by order items

In magento 1, I was able to filter orders by the following: $orderitem = Mage::getModel('sales/order_item')->getCollection(); $orderitem->addFieldToFilter('name',array('like'=>'%'.$value.'%')...
0
votes
0answers
19 views

Magento 2 collection filters for GRID are not working

I'm developing a module for Magento 2, but when trying to create a GRID, my filters are not working. I have some settings in other class and load it to the collection, using it inside the ...
0
votes
1answer
15 views

magento 1.9 | how setStockData on collection

i have this code $productCollection = Mage::getModel('catalog/product')->getCollection(); $productCollection->addAttributeToSelect('SKU') ->addAttributeToFilter('...
1
vote
3answers
33 views

Magento 2 + custom eav field value store in array

I have a custom eav structure and there is store_id save in array format in the database field. I need to filer collection with addFieldToFilter with store_id. $collection = $this->...
2
votes
0answers
9 views

How to create a pagination on product page for the reviews

I am trying to create pagination on product page just to keep the review down. I have over 50 reviews for product is there anyway I could limit it to 10. Is there anyway I could follow some codes or ...