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
1answer
911 views

Saving Order Collection

I'm trying to run an update script to a module as i've changed the way our warehouse module works. I need to update all orders in a collection of orders if it meets a certain requirement. I know that ...
0
votes
1answer
2k views

How to convert sql query to magento in order to fetch data

I am developing a custom module which will enhance the magento reviews and rating, now i have created a custom table which will count votes on reviews(facebook comment like). Now i have to convert ...
0
votes
1answer
35 views

How to check if _data is defined?

This is my code: $collection = Mage::getModel('orderhandling/paymentmapper')->getCollection(); $payments = $collection->addFieldToFilter('id', $id); Sometimes, if the id is not defined, the ...
0
votes
1answer
503 views

In a products collection have addAttributeToFilter 'check' child products of a configurable product?

For our API we have an option to use filters, these work great so far and are pretty simply made with the addAttributeToFilter function. However, the problem is that when a configurable product has a ...
0
votes
1answer
127 views

Help with Product collection filters

I’m writing a little script to hopefully pull a collection of products which match certain criteria - so far its working at its most basic using: $products = Mage::getModel('catalog/product')->...
0
votes
1answer
785 views

Load only certain attributes and map them, by collection

So I am using this code: $connection = Mage::getSingleton('core/resource')->getConnection('core_read'); $IDs = implode(',', $products); $sql = 'SELECT * FROM `catalog_category_product` WHERE ...
0
votes
2answers
594 views

Add a new row at start of grid collection of custom module grid tab

I have a collection ,which has total 30rows,Now,i want add new row at start of grid collection. Current code of prepareCollection() in grid.php protected function _prepareCollection() { $...
0
votes
1answer
3k views

Get color values used in products

Goal: I need to display on homepage a list of colors of products available at the moment in the particular store view. Description: Products have color attribute (the default attribute which exists ...
0
votes
1answer
692 views

Filtering orders by status containing space

I am building a php script for a magento site. The script is located in a subfolder to the document root and is called from cron/terminal. In this script I am trying to create a collection of orders ...
0
votes
1answer
1k views

Pagination broken by custom collection

Below is the code for creating a custom collection, but it is breaking pagination. It is showing only one item in pagination, When I am printing getSize() it is giving one(which is wrong), but on ...
0
votes
1answer
87 views

Change the way of price filter applied

I have a custom stock status attribute with 4 options. array( 4 => 'In Stock', 3 => 'Soon', 2 => 'Out Of Stock', 1 => 'Discontinued', ); I want change the way of price ...
0
votes
1answer
300 views

Ordering of collection changes depending on call method

I have the following piece of code: $model = Mage::getModel('catalog/category')->load(1); $collection = Mage::getResourceModel('catalog/product_collection'); $collection->addCategoryFilter($...
0
votes
2answers
4k views

Filtering products by multiple categories in Magento [duplicate]

I have some problem with filtering categories in Magento. The filter method which I used, display only one category, but I need to display few more. Here is my code: $products = Mage::getModel('...
0
votes
2answers
860 views

Manipulating list.phtml file's getloadedproductcollection

I've been trying to something for days and stuck! Need help. I'm trying to manipulate the getloadedproductcollection() method called in list.phtml file in catalog/product. I want to remove the ...
0
votes
1answer
394 views

How can I add payment_id and txn_id to Magento Grid?

I am trying to add payment_id and txn_id from the sales_payment_transaction table to a custom Grid.php module in Magento admin. I have been able to add the columns which DOES display the data but if ...
0
votes
1answer
449 views

“frontend_input” is null against attribute I have loaded

I assume I am doing something wrong when loading this attribute but when I do: $attribute->getFrontendInput() it's null. I have also tried: $attribute->getData("frontend_input") to no avail. ...
0
votes
1answer
5k views

Modify tax rate programmatically based on products without save in database

I need to apply different rates based on a custom attribute of product. I created an observer to change the rate before the cart (sales_quote_collect_totals_before). Everything works fine but when I ...
0
votes
1answer
2k views

Limit Collection Size to N-number

After several research attempts, I still couldn't manage to limit category page to N-number of products to be shown. I need to limit a specific category page to let's say 180 products only, with ...
0
votes
1answer
603 views

addFieldToFilter doesn't return the right product for selected attribute values

I am currently programming a product configurator module for Magento. Everything is working fine so far besides the core functionality: choosing the right product from the database for the selected ...
0
votes
1answer
3k views

Magento collection issues, methods not working filters not applied etc

Trying to create a couple of quick extensions, one to display a list of best sellers and one to display a list of items on promotion. I want both of these modules to filter by a given cateogry id if ...
0
votes
3answers
368 views

Collection fails when using a more restricted admin user

I have the following collection which helps implement a custom report. <?php class VMR_Customreports_Model_Resource_Productsordered_Collection extends ...
0
votes
1answer
326 views

Add a product collection to customer entity type

I would like to allow a logged in user to select his or her favorite products. This list should be maintained from a new account page to be created following Alan Storm his article: http://alanstorm....
0
votes
2answers
1k views

Trouble while getting product collection in observer

i am trying building a small module which house a Observer for getting called when and event called when catalog_product_import_profile_after is fired this is custom event which i have fired using the ...
0
votes
1answer
20 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
7 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
33 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
0answers
168 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
30 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 ...
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 ...
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
23 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
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 '%...
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
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
41 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
115 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
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 ...