We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [collection]

Questions related to Magento collections

Filter by
Sorted by
Tagged with
0
votes
3answers
23 views

Magento 2 Add new column in Customer Page from data from database

I would like to ask if there is an effective way to add column in Customer's Page Grid in magento admin. I have viewed all tutorials and same problems in the web but no luck on displaying the data. I ...
0
votes
1answer
18 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
0answers
6 views

Filtering orders in certain state that are still in same state some time later?

Magento 1.7.0.2 This is my collection code: $collection = Mage::getResourceModel('sales/order_collection') ->join(array('a' => 'sales/order_address'), 'main_table.entity_id = a....
0
votes
3answers
48 views

Custom module collection array not return

I have created a custom module and I have return collection array but it does not return foreach array in Magento 2.3.2. it returns the only foreach last value. Block Code <?php /** * @copyright ...
0
votes
2answers
31 views

Magento 2: How to add sub Query on left join

$collection = $this->rmaLogsFactory->create(); $collection->addFieldToSelect('increment_id'); $collection->getSelect()->joinLeft('rma_log AS arl','main_table.increment_id = arl.order_id ...
0
votes
0answers
56 views

How to show Bestseller products with brand(Manufactuerer) wise Magento 2

First I have refreshed the reports on best sellers on the admin panel it's giving me updated data on bestseller tables. I get all the products id's of the best seller but the issue is ...
0
votes
0answers
9 views

Magento | How create request to database to get data from eav_attribute_option_value table

i have this code //10 = Retail attribute $attributesToSelect = array('capacity','sku'); $productCollection = Mage::getModel('catalog/product')->getCollection(); $...
0
votes
0answers
11 views

Do I need to loop all children of the configurable product to know the stock of each product size?

In a shoe store I have the following configuration: For each color we have a configurable product, and in this configurable product we have size variations. We have a size filter ... when a customer ...
0
votes
0answers
21 views

How to send 'Out of stck' to back of the page Magento 2

How can I display In stock product first and Out of stock products back in catalog pages? I tried something like this, public function aroundgetProductCollection(\Magento\Catalog\Model\Layer $...
0
votes
1answer
30 views

Magento 1.9: Get Product details for a Customer Order

I am trying to get the product_id of each orders that the customer has ordered. One simple way is to fetch all the orders, and for each order have a loop to get all items for each order. Which will ...
2
votes
1answer
30 views

Magento 2.3 - limit certain categories products

We have a few categories which function like "bestsellers" categories; these categories can hold any number of products, but I'd like to show only the top four. So I figured to create an observer ...
2
votes
0answers
36 views

Magento 2 How to get collection in SOAP UI?

I am trying to get all SOAP api collection in SOAP UI, The initial step is wrong, Everytime it fails when I write Initial WSDL. Initial WSDL: https://127.0.0.1/magento/soap/all/?wsdl&services=...
0
votes
0answers
161 views

Magento2 Back End is working fine but front end is not working and showing This page isn’t working error

I am working on a Magento 2 project, and it was working fine until today, but now when I try to open it, the page is not working. The following error is coming in error log: PHP Fatal error: ...
0
votes
1answer
29 views

Magento 2 REST API Products - limit which custom_attributes returned

There can be a lot of custom attributes for a product and some have very long values. Is there a way to filter the responses to include just one specific attribute_code value? Note: this is not ...
1
vote
0answers
43 views

Magento 2.3 want to trace collection object

I am getting NULL in where condition of product collection query on category page. I want to trace where from NULL getting added. how can I trace collection query. I have tried debug_backtrace() as ...
0
votes
0answers
15 views

Filtering category products showing wrong count in layer navigation in Magento 2

I have used below code in, app/design/frontend/Custom/Theme/Magento_Catalog/templates/product/list.phtml <?php $_productCollection = $block->getLoadedProductCollection(); $_helper = $...
0
votes
0answers
25 views

Filter category product collection in list page with multi-select attribute Magento2

I need to override the method where the category product collection is fetching in list page. I have created a product attribute, which is multi-select attribute, the attribute values for individual ...
2
votes
0answers
23 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
8 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
17 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
21 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
32 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
22 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
30 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 '%...
3
votes
0answers
38 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
33 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.
1
vote
0answers
10 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
80 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
59 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
15 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
40 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
110 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
1answer
24 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 ...
1
vote
0answers
15 views

Magento 2 : Join customer collection with custom collection

\Block\Account\Message\Message.php public function getAffiliateCustomerCollection() { $customerId = $this->customerSession->getCustomer()->getId(); $...
1
vote
2answers
31 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
37 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
40 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
23 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
35 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
111 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
30 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
83 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
43 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
65 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