Stack Exchange Network

Stack Exchange network consists of 174 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

0
votes
1answer
25 views

Magento 2 custom module Collection join table _initSelect

My Collection.php .... public function __construct( \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Psr\Log\LoggerInterface $logger, ...
0
votes
1answer
14 views

Custom attribute saved but not loaded in collection?

I added a custom attribute is_featured to my Magento 1.7 store. Its a yes/no dropdown. I am setting it to yes on storeview level and to no on the standard level. Now I try to load a collection with ...
2
votes
2answers
22 views

addFieldToFilter `OR` condition for customer relationship in Magento 2

I have a custom module to store customer relationship, with database structure like this: |entity_id|first_customer|second_customer| entity_id => the relationship id first_customer => customer ...
0
votes
1answer
13 views

Magento 1.x addFieldToFilter using AND instead of OR (how can I join search using AND)

I am trying to use AND and OR based on user input. OR = success But I an unable to setup AND queries for addFieldToFilter question: how can I add the second (looped filter) using AND to join $...
1
vote
0answers
25 views

Magento 2: Sub category showing product from other sub category

I have a block class that extends \Magento\Catalog\Block\Product\ListProduct and tried to override the list.phtml with exactly the same file (say mylist.phtml), except it is located under my module. ...
0
votes
0answers
12 views

Magento catalog_product_collection_load_before on product list pages only

I have a module using catalog_product_collection_load_before event. And I want to use it on product list pages only. Not sure why but its being used on single product pages too. config.xml <?xml ...
1
vote
1answer
48 views

Magento 2: How to add where clause in grid collection

I am working on a module, where I have 2 custom tables. One is of all customer who have added product to First table(one customer can add multiple tables) and that first table is displayed on grid. ...
0
votes
0answers
18 views

How can I use 0 instead of null magento 2 collection?

I have created module to show report in grid. But in collection some fields contains null value how can I change null to 0. <block class="Magento\Backend\Block\Widget\Grid\Column" name="...
0
votes
1answer
37 views

Category collection with filter Magento2

I have created custom Drop down attribute for category with attribute_code is "is_homecategory" Used below methods to create it. Setup/InstallData.php public function install( ...
0
votes
0answers
22 views

magento 2 load resource model by multiple custom fields- equivalent to the addFieldToFilter method

i want to load my resource model by multiple customs fields. i am aware that i can load a collection with multiple field with the addFieldToFilter i.e as follows; $this->collection() -&...
1
vote
1answer
23 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
21 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
42 views

Cache a product collection by a key?

I have added a collection to buff out related products with extra "most viewed" products from a products top level category. This is a slow query and takes about 0.2 seconds so was wondering if this ...
1
vote
1answer
25 views

How can i get products from a remote database in real time by filters in Magento 2

This request is for an auto parts store. The products are filtered by car make, model, year, etc. When a client apply a filter I need to make an API call to manufacturer server, get products and ...
1
vote
0answers
33 views

How to sort a collection after load

I have a store collection. And it has the following fields [0] => Array ( [location_id] => 5 [title] => Los Angeles [description] => [status] => 1 ...
1
vote
2answers
60 views

Magento 2, addAttributeToSelect not working with product collection?

I am applying these fillers: $collection->addAttributeToSelect('name'); $collection->addAttributeToSelect('sku'); but every time getting full record as comes form: $collection->...
1
vote
3answers
33 views

Product collection by category id, gives zero products

The following code, returns an empty collection in most categories, even if the category indeed has products: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $...
0
votes
1answer
28 views

Magento 2: Parsing Item information through block

Good day, I want to create a phtml file and create a dynamic block with that one to put on CMS pages - Take it as product information blocks where i want to display the product name, the price, the ...
0
votes
3answers
50 views

How to prevent memory consumption during collection enumeration?

In the following script: $pageSize = 1000; $productCollection = Mage::getModel('catalog/product') ->getCollection() ->addWebsiteFilter($website->getId()) ->...
0
votes
1answer
25 views

Retrieve Compare Items Collection returning zero Items Magento 2

While I am trying to return compare items in custom module phtml file, it is returning zero items but in database table catalog_compare_item showing all the added items to compare. Class Used : ...
0
votes
1answer
16 views

Magento 2 Get product collection filter by atributes does not give the exact match

I have created a filter to get product bellow is an examples: $filter = array( array('attribute' => 'color', 'eq' => '2'),//id of option array('attribute' => 'size', 'eq' => '5'),// ...
0
votes
1answer
19 views

What is the role of visibility filter in colections Magento 2?

I am getting Order Items, from order collection by Order ID but as from the attached screen shot (Order 15) I am getting one product data two times. Can any body explain the reason and what will be ...
2
votes
0answers
21 views

Check if 2 dates already exist in collection filtering

i have a custom collection which has database column start_at and end_at in Y-m-d format , i try to do some validation before inserting to database, one of them is make sure the period between ...
0
votes
0answers
19 views

magento 1 custom report collection initselect issue

I created custom report module named Hs/Paymentreport and Collection file extends Mage_Sales_Model_Resource_Report_Collection_Abstract class. In my collection class file, __construct() method looks ...
1
vote
0answers
53 views

Magento 2 : how can i add my custom filter in custom admin grid

i have created custom admin grid which shows the log of login customer, every time customer login successfully the log will be added in that grid even if same customer, what i want to do is add my ...
1
vote
1answer
21 views

Alter getProduct collection

I need to alter the equivalent of native "getProductCollection", but I don't know how and where to do this. I need the getProductCollection to look like this : public function getProductCollection() ...
0
votes
1answer
32 views

Get all guest & customer email id's in single collection Magento 2

I am trying to list all unique email id's (guest & customers) in admin grid to restrict specific email id to place order. For that, I got an id's from customer collection and order collection. ...
2
votes
1answer
73 views

Magento 2.2.6: Product collection does not apply the filter

EDIT: I have seen that in magento 2 the ListProduct page is cached, for this reason once loaded it does not enter. Is there any way to modify the query returned by ListProduct? I extend the class: ...
0
votes
1answer
44 views

Magento 2 Join Product Collection with Custom CollectionFactory

In Magento 2.2.5, I have Custom Model Collection (followed this tutorial). In that I want to add the Product Collection into this custom collection by default. How to achieve this.
0
votes
1answer
28 views

RewardspointsFactory class does not exist

Please anyone review my code. Facing this error. Exception #0 (ReflectionException): Class Sugarcode\Test\Model\ResourceModel\Test\RewardspointsFactory does not exist Exception #1 (ReflectionException)...
1
vote
1answer
39 views

Duplicate entities in collection

I'm trying to extend Products in carts report grid. I needed to separate products for each customer and add a Customer name column. So for example a product with id number equal to 123 may exist in ...
1
vote
1answer
26 views

unable to solve the error in magento2

I need to solve this below error, Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught TypeError: Argument 1 passed to Webkul\Pos\Model\...
0
votes
0answers
19 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\...
2
votes
2answers
69 views

Magento 2 Get Product ViewCount Value By Factory

Trying to get most viewed product view count value, I need to use it in another method calculations. E.g.(if most viewed product view count value is 100 then I need this value to be returned) What am ...
1
vote
3answers
36 views

Error in collections

I had an error like below, Fatal error: Uncaught TypeError: Argument 5 passed to Webkul\Pos\Model\ResourceModel\Agent\Collection::__construct() must be an instance of Magento\Framework\App\...
3
votes
1answer
34 views

How to create a addnametoselect function for custom tables

I need to create an addnametoselect function (like in customer collection) for filtering purpose in the custom collection filter by the fields in custom Table on DB in magento2. Please, anyone, help ...
0
votes
0answers
30 views

Sort categories children by position

I want to sort categories children by position. What i mean: I have this code which gets categories collection and then puts those categoris in an array of items (items = category). $result = []; ...
1
vote
1answer
133 views

Magento 1 - Convert Object into an array value

I was trying to get the information of tracking in the UPS. I got on of the method from the core (app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php => method name getTracking($trackings)) that ...
2
votes
1answer
87 views

Magento 2: How to get Customer collection filter by Full name like admin grid?

How to get Customer collection filter by Full name or by keyword like admin grid of magento 2?
0
votes
1answer
27 views

SKU Report for null attribute values

I am getting all product sku's that does not have a attribute value 'image_link'. I have written this code in magento : $products = Mage::getModel('catalog/product') ->getCollection() ->...
1
vote
0answers
26 views

How to get collection from database in phtml not from cache when full cache enabled

I have created an extension which I have uploaded in the marketplace but marketplace rejected due to cacheable="false". <block class="Company\Module\Block\Hello" name="information" template="...
2
votes
1answer
41 views

Group Collection to Filter Unique Products Based on a Specific Attribute

Scenario: A store catalog is populated with configurable products each having several children with different sizes and colors. As the goal is to show the different color variations, only the ...
0
votes
0answers
13 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
1answer
26 views

Mysql FULL JOIN in magento 2

How can i execute something like full join in magento 2 then set query data in my collection. Below i try to do somethig. $joinLeftCustomerSql = $connection ->select() ->from("$...
0
votes
0answers
15 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->...
1
vote
1answer
39 views

Magento2 | MassAction Filter instance none given

I'm getting strange error when I want to use mass action in a grid : AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to Toto\\Helloworld\\Controller\\...
0
votes
0answers
27 views

Modify the existing product collection in magento 2

I need to modify the existing product collection in magento 2. Product name, description, image etc are loaded from the third party url and inventory & pricing details are from magento db itself. ...
0
votes
2answers
61 views

Call to undefined method addFieldToFilter() in magento 2

I have a model,resource model,collection file shown below. app/code/Magge/Custom/Model/Categrory.php namespace Magge\Custom\Model; use Magento\Framework\Model\AbstractModel; class Categrory ...
2
votes
1answer
149 views

how to retrieve Coupon Code by rule Id on Checkout Success Page?

I have coupon rule collection created at admin side and displaying rule names in the system configuration of the custom module. Actually, I wanted to get coupon code of a cart rule that has been ...
1
vote
0answers
31 views

override getLoadedProductCollection of \Magento\Catalog\Block\Product\ListProduct

I am overriding getLoadedProductCollection() in my block where performing some custom query public function getLoadedProductCollection() { $myCategory = $this->...