All Questions
Tagged with collection magento2
180 questions with no upvoted or accepted answers
1
vote
0
answers
880
views
Magento 2 - How to use mysql find_in_set?
In Magento 2, I try to use find_in_set mysql function but without success.
I try this :
$result->getSelect()->order("find_in_set(e.entity_id,'".implode(',',$sort_order)."')");
But it give me ...
1
vote
1
answer
123
views
For each Loop Not Print Proper Data
On product listing page I have $_productCollection = $block->getLoadedProductCollection(); if I call getData on $_productCollection I get different array than I get in foreach loop. Does anyone ...
1
vote
1
answer
2k
views
Magento 2: Filter Product Collection using Category Id always return empty set
I have a parent category with subcateogry that contains a lot of product in it, when i tried to filter the product collection using this parent category id, it always return an empty collection:
...
1
vote
0
answers
96
views
Limiting the number of drop-down options
I have created an attribute which consists of two option. say A and B and on the front-end, I have another attribute which is a drop-down. Is it possible to limit the number of options in the front-...
1
vote
0
answers
77
views
is there any way to display all my products in group product on one page in admin dashboard
Basically this is my group product
and this is how we can see all of child products
Now I dont want that previous and next button i just want all my products in list comes in one page or tab.
help ...
1
vote
0
answers
264
views
Magento 2 - Category filter on custom search page
I have custom search page that is working perfectly and all the filters are applying properly except category filter.
Following is the code:
$indices = $this->searchResult->getIndices();
...
1
vote
1
answer
440
views
Magento2: What is difference between ProductFactory and CollectionFactory?
What is the difference between this below code?
Class : \Magento\Catalog\Model\ProductFactory
Code : $this->productFactory->create()->getCollection();
Class : \Magento\Catalog\...
1
vote
0
answers
38
views
Magento 2 Collection path wrong but still module is working and saving the data,how possible?
I am developing a custom module to save data in custom table. I have created model and resourcemodel classes and also collection.php
<?php
namespace Vendorname\Modulename\Model\ResourceModel\test;...
1
vote
0
answers
536
views
Apply Magento\CatalogRule\Model\Rule\Condition\Combine to a collection FAST
I am using Karliuka m2.SmartCategory module for dynamic categories. This seems great to do what I need as was having issues with Smile modules virtual categories and this seemed to offer the same ...
1
vote
0
answers
33
views
Magento 2 collection filter need advies
We have grouped products - rims. Now we want to sell it with tires.
Logical is to look up for needed tires and show them, although the problem is if we do that we get results for front and back. but ...
1
vote
0
answers
1k
views
Magento2: How to set pagination for wishlist?
As my default wishlist collection which is coming from block is not working due to the applied theme in my magento2 site.
So, I applied the collection on my list.phtml file. And the problem is I need ...
1
vote
1
answer
1k
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('*')
->...
1
vote
1
answer
1k
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 ...
1
vote
0
answers
280
views
Magento 2 : Join customer collection with custom collection
\Block\Account\Message\Message.php
public function getAffiliateCustomerCollection()
{
$customerId = $this->customerSession->getCustomer()->getId();
$...
1
vote
0
answers
506
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(...
1
vote
1
answer
1k
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.'%')...
1
vote
3
answers
103
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->...
1
vote
0
answers
189
views
Magento 2 : Need to set custom category collection using plugin
I want to set custom category collection using the plugin.
I created plugin about Magento\Catalog\Block\Product\ProductList\Toolbar this block and aroundSetCollection(). But, not actual output I ...
1
vote
0
answers
56
views
how to use walk method to join two tables in magento 2
friends,
how to use the walk() method to join two tables in Magento 2
I have 2 tables and I want to join them based on some conditioning.
my present code looks like this
$result = array();
$...
1
vote
0
answers
259
views
Autocomplete with ul li input in Magento2.2.5?
I want to show the value in autocomplete.
Refer my code below:
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script>
<script>
<?php
$zipdata = array();
...
1
vote
0
answers
152
views
How FIlter Order Items Collection?
How Filter(make custom array) Order Items Collection when view order from front end admin page sales order grid.
1
vote
1
answer
301
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
0
answers
316
views
Magento 2 searchCriteriaBuilder for multiple collection
I want to create search functionality for customer to search his invoice order etc.
For this I'm using searchCriteriaBuilder and \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface
...
1
vote
1
answer
46
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
1
answer
29
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()
...
1
vote
3
answers
729
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\...
1
vote
0
answers
233
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="...
1
vote
0
answers
497
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->...
1
vote
0
answers
528
views
Pagination not working in custom grid collection
I have created the grid with custom collection filter grid displayed proper but pagination not working. Any have an idea about the same. Please find below my code
<?php
namespace Abc\Xyz\Block\...
1
vote
2
answers
9k
views
how to get block data on phtml template in magento 2
what is missing in my code block data not shown in phtml template
block page
namespace xxxx\Trails\Block;
use \Magento\Framework\View\Element\Template;
use \Magento\Framework\View\Element\...
1
vote
1
answer
1k
views
Use search_criteria to filter custom extension collection in Magento 2
I generated a custom extension with a custom model collection from mage2gen , is it possible to implement the search_criteria like when you retrieve product using rest api? what i know is the product ...
1
vote
1
answer
184
views
Magento 2.2.3 :: How to check if ProductCollection exists?
Here is my problem: I have a vehicle parts site which lets user select their specific model and be saved via a cookie. Then the whole site will be filtered via my module plugin, where I override “...
1
vote
1
answer
1k
views
Magento2 does n't get the order collection from Order\CollectionFactory
I am using the Magento2.2 version .
I am using the class Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
to get the order collection.But getting the error
Fatal error: Uncaught Error: ...
1
vote
1
answer
727
views
Magento 2.2 product collection doesn't return out of stock products
Magento 2.2.* seems to make it very difficult to get out of stock products in a collection! I have the following code which works fine in Magento 2.0 and 2.1:
use Magento\Framework\View\Result\...
1
vote
0
answers
1k
views
Magento 2: Delete duplicate products programatically
I need to search Magento 2 DB for duplicate SKUs and remove duplicate products using a script, i found a very useful script here:
Remove duplicated products from catalog.
but it's not compatible with ...
1
vote
0
answers
356
views
convert direct sql to collection in magento 2
How we can convert direct SQL query to collection ?
SELECT wk_mpauction_winner_data.auction_id, wk_mpauction_winner_data.customer_id, quote_item.created_at AS quote_item_date ,sales_order_item....
1
vote
0
answers
239
views
Manadev Multiple Select and Sort By Price not working
I have installed Manadev Multiple Select extension which i thought was pretty good for a while until i noticed the sort by price didn't really work. I cannot quite figure out why however have enabled ...
1
vote
0
answers
394
views
magento 2 get product collection with custom filter on product listing page
I want to apply my custom attribute filter in category product collection?
Can any one inform me for that ,i need to override which file ?
1
vote
1
answer
269
views
Fetch a specific model in magento 2
I have 2 ways to fetch a model object:
$orderId = 18;
/** @var \Magento\Sales\Model\Order $firstOrder */
$firstOrder = $this->_orderFactory->create()->load( $orderId);
/** @var \Magento\...
1
vote
1
answer
2k
views
Magento-2 How to get custom product collection in catalog search result based on particular category
I am working on custom module for catalog access. It requires only logged in customer to access the assigned category products.
Right now in catalog search result, product collection displays all the ...
1
vote
0
answers
883
views
How to load a model with relationships via repository in Magento 2?
Background story:
I was trying to load a model with model_store relationship using this snippet. I failed to do that with my own model. Model is being loaded without store data. Some debuging later I ...
1
vote
1
answer
293
views
Magento 2: Guide for All Collections
For now, I'm not able to find any guide for this. If I need to get all collection say for Example all Orders List
so I will go to Vendor Magento Folder, Particular Module's di.xml file & checking ...
1
vote
1
answer
421
views
Magento2: How can I fetch the email transaction grid collection in my custom extension?
I am working on one custom module and I need to fetch the transactional email templates grid which is at Marketing > email templates in magento 2 default.
I need that grid in my custom extension, how ...
1
vote
4
answers
8k
views
Magento 2: How to set visibility and status to product using collection?
I'm creating a cron to pass through all the products and set them visible and active.
This is my execute of the cron who runs well:
public function execute(){
/**
* @var $item \Magento\...
0
votes
1
answer
67
views
Magento 2 SimiCart - Magento 2 Mobile App Builder
We are using Magento 2.4.2-p2 version with SimiCart - Magento 2 Mobile App Builder
We are struggling from where category_id is coming
File name - app/code/Simi/Simiconnector/Model/ResourceModel/...
0
votes
0
answers
29
views
List products including out of stock products in custom module (without listing out of stock products on the whole shop!)
I’m having a custom route in a custom module where I’d like to list a subset of products for a specific search criteria. I’d like to include here just for this action the out of stock products.
BUT I ...
0
votes
0
answers
47
views
Show Image Banner between the date
I am displaying my banner on the page, it is displaying correct.
I want to show the Banner between the dates from the "display_from" to "display_to".
I am getting my all date in ...
0
votes
1
answer
741
views
How to load a custom product collection in frontend using smile elasticsuite
Everything is in the question i need to load a custom product collection in frontend using smile elasticsuite. But i can't figure out how to do it. Do you guys have a working example ?
"smile/...
0
votes
3
answers
721
views
How can I remove a condition from a collection
I tried to use two methods to reset or clear the collection but it didn't work.
I am working with the category collection on which I want to remove this part of the condition : (e.created_in <= '...
0
votes
2
answers
511
views
Convert SQL Select Query to Magento Collection
I have a complex sql select query which actually returns sales report against specified categories. I want to load data as a collection to display but I'm not able to convert the query into Magento's ...