Stack Exchange Network

Stack Exchange network consists of 175 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 tagged [collection]

Questions related to Magento collections

6
votes
1answer
480 views

How can I get only the Store View attributes, without the inherited Global data? I only need the diffs

I'm using the internal Magento APIs to get the product data on a store view level. I only want to get the values that are on that store view level, not the global values that in inherits. But it ...
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 ...
4
votes
1answer
385 views

How to use collection factory model in Unit Test magento 2

I have a custom extension with model with structure like this in database: +----------------------------------+ |entity_id | customer_id | balance | +----------------------------------+ | 1 | ...
4
votes
1answer
775 views

How set order with custom field column magento 2

I want to setOrder with custom field column in get list product. I override toolbar.php but it's not working di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
4
votes
1answer
1k views

How can Set filter collection in custom model by product id magento 2

I want to filter collection in my custom model by product id to load the filter data value in admin grid. My Model:- Vender\Modulename\Model\Outofstock namespace Vender\Modulename\Model; class ...
3
votes
1answer
554 views

Magento 2 : Is there a way to query products using Custom Attributes in Rest API Call?

I have a custom attribute setup for Books called isbn_13 Now I try to find the products using the isbn_13 values but unable to filter the results based on this. Is there any way to do this? Update: ...
3
votes
1answer
326 views

Getting data from quote items collection issue in M1

This is my collection: $collection = Mage::getModel('checkout/cart')->getQuote()->getItemsCollection() ->addFieldToFilter('product_type', ['eq' => 'bundle']); $...
3
votes
1answer
443 views

Magento 2: performance of getCollection function

I'm currently working on a Magento 2 theme that requires collection statistics to show on the frontend. For example: what are the total number of customers at the moment. I'm using \Magento\Customer\...
2
votes
1answer
74 views

How to filter customer collection with its attribute?

I've bunch of customer attributes, So how can I filter customer collection with its custom attribute ?
2
votes
1answer
187 views

how to append variable in LIKE in SQL Query

I have a SQL query where I want to append $customerID, how to achieve that? > SELECT `e`.*, `at_assigned_campus_manager`.`value` AS > `assigned_campus_manager`, `at_physical_verify`.`value` ...
2
votes
1answer
69 views

how can i add a two year filter to my reports in magento 1.9

I want to add a two year interval filter to customer order by report grid ,but I have no idea about this.Anyone who have tried it please find me a way ,thanks in advance. I found to add code here in ...
2
votes
1answer
3k 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 <...
2
votes
1answer
582 views

Product filtering with multiple attributes

I want to display all the product with some product attribute features. ie; I have 3 products in kids category with attributes and categories like Category: boy and girl Size: small, medium,large ...
2
votes
1answer
273 views

Supplier is not being shown in Grid Filter in catalog product grid

I have copied file app\code\core\Mage\Adminhtml\Block\Catalog\Product\grid.php to app\code\local\Mage\Adminhtml\Block\Catalog\Product\grid.php and have added some extra column like Special price, ...
1
vote
1answer
24 views

Magento 2 - Recently viewed product collection from Model

Please read description carefully before marking it as duplicate I want to get recently viewed product collection from Model instead of Block I have check similar post but no one answered it ...
1
vote
1answer
30 views

Magento 2 - Display out of stock product for only one category while hiding them in all other category

How to display out of stock products only in one category with "Display Out Of Stock" option "No" in the admin?
1
vote
1answer
71 views

How to display only USA states as a select drop-down in custom phtml in Magento2.2.5?

I want to display only USA states as a select drop-down in custom phtml in Magento2.2.5? Any help would be appreciated.
1
vote
1answer
28 views

Magento 1.9 collection multi conditions

I read many posts and articles but still didn't find a solution. I would like to filter my product collection with this condition: ... WHERE ('supplier_id' = 1 AND 'product_type' = 'first_type') ...
1
vote
1answer
256 views

How to delete object from collection in magento2

How to remove any object from magento 2 collection. If we have collection of products and we want to delete product which is at first index . how to delete that product without deleting it from ...
1
vote
1answer
160 views

Magento 2, filter product collection by sku while preserving the given array sequence

Using below code, collection is filtered. If $productSkus array is like Array ( [0] => 5714156000153 [1] => 8690604469871 [2] => 6412616365413 ) after filtering I see the collection is in ...
0
votes
0answers
47 views

Magento 2 - Apply filter on Product collection

Is there any common event or plugin to apply the filter to product collection which includes product list page, related products list as well as upsell and cross-sell product list? If no, then how ...
0
votes
0answers
65 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\...
0
votes
0answers
17 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
0answers
23 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->...
0
votes
0answers
13 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
0answers
35 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
14 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
30 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 ...
0
votes
0answers
25 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 ...
0
votes
0answers
22 views

How can I apply natural sorting to a collection in Magento 2?

I want to sort a collection in Magento 2 using natural sort. I know a can do a simple $collection->getSelect()->order(...) to do the sorting directly in MySQL, and I know that would be the ...
0
votes
0answers
166 views

Delete quote which has not been converted to order

How to delete quote collection which has not been converted into order and the quote was created yesterday and the day before that ?
0
votes
0answers
434 views

Magento 2.2.4 wishlist count not display on top of the product category page

I used my custom theme, i facing some problem related to wishlist count. Wishlist count display on product detail page but not display on product category page, Home page and other pages. i am stuck ...
0
votes
0answers
187 views

How I can Filter admin Order collection by status (Pending Only)?

How can I filter admin order collection and showing only pending orders in grid? So how can I extend it in custom module? Any suggestion about that?
0
votes
0answers
40 views

How to limit products category based per user in magento 1.9.1.0?

I want to limit products category based per user. For example, If I have added free category under 10 products. Users only can order 1 to 7 products within free 10 products. Any idea regrading this?
0
votes
0answers
407 views

Magento pagination how to set page number for custom collection?

I have a custom collection of around 900 wordpress blog posts I have used custom pagination for this custom collection. The problem is, when i click on the pagination button, the pager URL seems to ...
0
votes
0answers
67 views

Magento 2: How to add Join query in a custom module

want to add join query in getPost function in a single view public function getPost() { if ($this->_post === null) { /** @var Post $post */ $post = $this->...
0
votes
0answers
169 views

convert sql query to magento collection

I am having a complex SQL query to make a custom report & showing same to custom report grid but somehow not able to convert the query into Magento's equivalent Collection. SELECT SUM(order_items....
0
votes
0answers
376 views

Custom Customer Attribute filter on search criteria Magento 2.1.8

I am trying to get customer collection based on email_id and my custom customer attributes i.e phone_code and mobile_number. When I only add email filter getList return's customer array object but ...
0
votes
0answers
496 views

Join tables with foreign key relationship

I wrote an admin module with a form, which consists of a text area and a dynamic-row form component. My data is split up in two custom tables with a FK/PK relationship. I need to populate my form ...
0
votes
0answers
322 views

Magento sales_order_grid + join concatenated results from other query

We have some queries / extensions adding columns to the sales_order_grid as a 1:N relation. Normally 1:1 relations work fine. 1:N relation need a group by statement on increment_id and use ...
0
votes
0answers
105 views

Magento 2 not able to get creditmemo collection

I am trying to get credit memo collection with following script but am unable to get the collection class Creditmemosync extends \Magento\Framework\App\Action\Action { protected $helper; protected $...
0
votes
0answers
28 views

Error when adding multiselect attribute

I am trying to add a multi select attribute with a collection ( custom created ) , the attribute has been added successfully but when I edit collection to fill this new field value it shows an error ...
0
votes
0answers
277 views

How to add , another model collection data to an array. : magento 1.9

I have response collection $customerData, i have to add referral code of selected customers in the same array, model and field of referral code is : $referCustomer = Mage::getModel('...
0
votes
0answers
113 views

How to Dispatch catalog_product_collection_load_after zero products in Magento 2.1?

I noticed that in Magento 2.1 the event catalog_product_collection_load_after is dispatched only when the collection has at least one product. How can I make Magento dispatch it also when the ...
0
votes
0answers
185 views

Grid Page for custom collection in Front end

We have a marketplace website, where we have list of vendors. In a page, we need to list all vendors for customers, So that customers can search and filter by Vendor's group, name, location. It ...
0
votes
0answers
119 views

Magento 2: Update Multiple Tables At Once

In Continue with Magento 2: How many tables required to change Order Status Programmatically? I have below code $orderIds = array(); $objectManager = \Magento\Framework\App\ObjectManager::...
0
votes
0answers
74 views

Magento 2: Conver SQL Query to Magento Format

In addition of Magento 2 How to set group by in Collection query? I have below query now. SELECT t1.* FROM messages t1 WHERE t1.id = (select max(id) from messages t2 where t2.posts_id = t1.posts_id ...
0
votes
0answers
49 views

Group products when showing recently sold items using sales/order_item

I can show the most recently sold items and sort them based on created_at using this: $itemsCollection = Mage::getModel('sales/order_item')->getCollection() ->setOrder('created_at', ...
0
votes
0answers
507 views

Get CatalogInventory stock collection in Observer

I need, on website save, get the inventory with the current website ID. Ad I'm trying to get the CatalogInventory Stock Collection in an Observer, but it finish with the error: Configuration array ...
-1
votes
0answers
19 views

add multiple filters in model data in magento 1.9

I want to apply the filters to the model file without collection in model file. Means when I load model like this Mage::getModel('modulename/modelname')->load(id) filter should be apply directly ...