Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
2 votes
1 answer
128 views

Magento 2 - All products attributes updated after update from collection

I have got collection in $collecction from Magento\Catalog\Model\ResourceModel\Product\CollectionFactory with some certain conditions I am updating a custom attribute viewed_count in foreach loop ...
Shoaib Munir's user avatar
  • 9,572
2 votes
1 answer
497 views

Magento 2 - Need to filter comma seprated values in addAttributeToFilter along with category filter

I need to filter comma sperated values in addAttributeToFilter in magento 2 Here is my Code: $comma_separated_values = 26,27,28,29; $categoryProducts = $category->getProductCollection()->...
Shomita's user avatar
  • 1,123
1 vote
1 answer
1k views

How to get product random collection in magento2?

I want to get the random 10 products from whole product collection in magento2. $productCollection = $this ->productModel ->getProductCollection() ->...
Mahi M's user avatar
  • 2,540
0 votes
1 answer
2k views

array convert into Magento 2 collection

I have 2 collection 1 is $bestsalecollection that show in dashboard . second is product collection. After filter collection when i return it generate error Call to a member function isLoaded() on ...
HaFiz Umer's user avatar
  • 1,690
4 votes
1 answer
1k views

Custom FilterList incorrectly sets Collection size in Layered Navigation

In order to add a custom filter to the Layered Navigation, I overrode the class Magento\LayeredNavigation\Block\Navigation\Category to load my own FilterList class instead of the one from core. My ...
Dorni's user avatar
  • 73
1 vote
1 answer
150 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 ...
Shoaib Munir's user avatar
  • 9,572
4 votes
2 answers
2k views

Magento 2.3 - Add product name column in custom ui grid with product name filter

I have added product name column in my custom ui grid. In which data displayed properly but not filtered grid by product name. Note : I set product name with comma separated in ui grid column. Here ...
Emipro Technologies Pvt. Ltd.'s user avatar
2 votes
1 answer
1k views

Magento 2 - Multiple collection on same block

I have a block where I want 3 different collections with different category filters. I have created collection object in constructor like this: protected $collection; public function __construct( ...
Shoaib Munir's user avatar
  • 9,572
3 votes
1 answer
642 views

Magento 2 - Multiple categories filter on product collection

I have a product collection $collection which is created by Magento\Catalog\Model\ResourceModel\Product\Collection code is: $collection = $objectManager->create('Magento\Catalog\Model\...
Shan Atif's user avatar
  • 147
3 votes
2 answers
846 views

Magento 2 call list.phtml with custom collection

I have custom collection in $collection I want to pass it to list.phtml so that I don't have to create listing UI again. I am trying to do this but it is not working <?php echo $this->getLayout(...
Magedev2301's user avatar
1 vote
1 answer
4k views

How to use Magento 2 cache?

I have a requirement where, I have huge custom data(around 5000) to display in a page. Currently, I have displayed them in a table and it takes time when I load the page. I want to save the collection ...
Gaurav Agrawal's user avatar
2 votes
0 answers
655 views

how to do pagination to display collection at admin panel custom table in magento 2

I'm trying to create a pagination for my collection to display in a .phtml file, but am getting error page Invalid template file: 'Magento_Theme::html/pager.phtml. Here is my code: code/...
Praveen Negimani's user avatar
1 vote
2 answers
397 views

Get recently viewed product collection Magento 2.3.1

I have tried this but it is not working. I am getting blank array. Suggestions please, i am stuck. I want to display recently viewed product in owl carousel. But getting no products. protected $...
Shweta Danej's user avatar
0 votes
2 answers
4k views

how to update data in database table

I am sending data to the database by checking duplicate data. But I can't be inserting/updating data in the database. protected function saveEntityFinish(array $entityData, $table) { $...
Praveen Negimani's user avatar
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 ...
Ankita Patel's user avatar
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(); $...
Adarsh Shukla's user avatar
6 votes
2 answers
1k views

Empty Collection :: CollectionFactory Approach and getCollection approach both give empty result

Magento 2.3.1 Php7.2 Ubuntu 18.04 I have created a table in my database using db_schema.xml and then populated that table with sql insert commands directly in mysql workbench. My model code is &...
PhantomS's user avatar
  • 503
3 votes
3 answers
5k views

Magento2 Alternate of Method getCollection() which is deprecated

I have checked the similar post: Magento2.2 getCollection from Factory deprecated But I still don't find the answer of it. I am calling getCollection() function, and PHPStorm saying that this ...
Shoaib Munir's user avatar
  • 9,572
0 votes
1 answer
440 views

Magento 2 : AddAttributeToFilter with AND Condition

In product collection, I want to do like : $productCollection = $this->productCollectionFactory->create(); $productCollection->addCategoriesFilter(['in' => $catalog_id])->...
Emipro Technologies Pvt. Ltd.'s user avatar
1 vote
1 answer
409 views

Recevied Empty array after using getItemsByColumnValue() collection method

I'm trying to retrieve a row from a custom table named 'lmap_shipping_tablerate' using a specific value for a column postcode. An empty array is returned when following line is used in my ...
PhantomS's user avatar
  • 503
2 votes
2 answers
1k views

How to update record using multiple conditions in CollectionFactory magento 2

I am trying to update the record but it creates a new record. Collection factory <?php namespace Webkul\Mpquotesystem\Block; use Webkul\Mpquotesystem\Model\ResourceModel\Quoteconversation; ...
prabhakaran7's user avatar
  • 1,125
3 votes
2 answers
2k views

Get all simple products of a category including not visible individually products - Magento 2

I need to get all simple products of a category. By using the following code, I'm getting only products which has visibility of Catalog, Search but not Not Visible Individually products. $categoryId =...
Vinoth Kumar's user avatar
0 votes
1 answer
138 views

Magento2: unable to get Actual result by using getSize()?

Collection protected function _getProductCollection() { $tagModel = $this->tagTagFactory->create(); $this->_productCollection = $this->_productCollection ->...
Unknown's user avatar
  • 581
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(); ...
Amy's user avatar
  • 945
4 votes
1 answer
3k views

Is there a way to select a field to be returned when using the getList() function within a Repository?

MAGENTO v2.2.6 To better illustrate my question here's an example. When using the ordinary collection I can limit the attributes/fields returned like so: NOTE: I wouldn't normally use the object ...
NSwanson7's user avatar
  • 453
2 votes
1 answer
6k views

Magento 2 get special price product collection

I want to get all sale products (which have specila price and special from date and special to date) in a .phtml file. Which i use in any where in store.specially in list page.
Hafiz Arslan's user avatar
3 votes
0 answers
53 views

how to use filters for new collection

I use in my decision the answer that was in this question Magento 2 Custom Collection Everything works fine, but how to filter data when they are searched? My code $collection = $this->...
Denis Maksiura's user avatar
2 votes
1 answer
432 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?
Pribhav's user avatar
  • 468
2 votes
1 answer
4k views

Magento 2 : addAttributeToFilter, addAttributeToSelect, addFieldToFilter not working

I created eav entity module. But, when I use this addAttributeToFilter, addAttributeToSelect, addFieldToFilter function in my custom module collection. It's not working. My collection file : I ...
Emipro Technologies Pvt. Ltd.'s user avatar
3 votes
0 answers
639 views

Order Collection based on Multiple Select Option Values Magento2

I have a list of products (books) with a custom eav multiple select attribute named 'authors' in magento 2. This attribute is 'visible_on_front' and also 'used_for_sort_by'. I am trying to use that ...
Emanuel's user avatar
  • 43
0 votes
1 answer
159 views

Model Collection.php magento 2

I cant seem to find any information why we need to create a Collection.php file inside ResourceModel and what is the purpose of collection.
PhantomS's user avatar
  • 503
3 votes
2 answers
804 views

Order Items Collection in Order Detail Page

This snapshot of order detail page. I Just want to known that which file or function call for setting this collection in this page. I want to just get Selected (Filter Row) Items Order.
HaFiz Umer's user avatar
  • 1,690
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.
HaFiz Umer's user avatar
  • 1,690
2 votes
1 answer
252 views

Order admin grid by values in another collection

I have a module, in this there is a field which contains the id from customer table. In my admin grid listing I show the name of the customer, not the id. When i short this grid by the field, the ...
Gabriel Fernandes's user avatar
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.
Amy's user avatar
  • 945
2 votes
2 answers
1k views

Magento2 filter not working for request parameter for order grid

I want to filter Sales Order query based on request parameter passed in querystring like following: http://127.0.0.1/website/admin/sales/order/index/key/...
bhargav shastri's user avatar
1 vote
1 answer
990 views

How to get 6 random product from a catregory in magento 2

I want to get 6 random product from same category on product page in magento 2
Waqar's user avatar
  • 974
1 vote
3 answers
938 views

How can I use mysql functions when I use collection filters?

How can I use something like this one NOW() - INTERVAL 10 DAY in collection filter? ->addFieldToFilter('period', ['gteq' => 'NOW() - INTERVAL 1 DAY']) Before running the query, the value in ...
Luigi T.'s user avatar
  • 332
2 votes
3 answers
5k views

Collection not loading in Ui Component Admin Grid - stuck spinning

I have a basic CRUD repository setup, however when I try to go to the Admin Grid UI Component, the spinner just spins and nothing loads. No errors displayed in any of the logs either. When I inspect ...
Erik B's user avatar
  • 165
0 votes
1 answer
140 views

Magento2 add custom values in collection->setOrder

I need to add some custom values in setOrder() of a collection, but it is not working. $collection->setOrder("((lat - ".$lat.")*(lat - ".$lat.")) + ((lng - ".$lng.")*(lng - ".$lng."))", 'ASC'); ...
VIPIN A ROY's user avatar
3 votes
3 answers
2k views

Get products collection in cronjob

I have a cron file like Col.php. I want to get products collection in my cron file. code in my file: public function execute() { $objectManager = \Magento\Framework\App\ObjectManager::...
Shoaib Munir's user avatar
  • 9,572
2 votes
1 answer
1k views

Sort collection by discount

I want to sort my collection by discount percentage for my sale category, I don't know if it is possible in Magento
Atif Ameer's user avatar
1 vote
3 answers
3k views

Modify product collection in M2

I am overriding Magento\Catalog\Block\Product\ListProduct In function _getProductCollection I have added some extra code. public function _getProductCollection() { $collection = parent::...
Daniel_12's user avatar
  • 680
0 votes
1 answer
72 views

Not able to save an item magento 2

I have a table which store certain data in database. First i am checking if the content is already there in the database if yes then update it else insert a new data. $sync = $this->...
Avesh Naik's user avatar
  • 1,251
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 ...
ravichandra's user avatar
0 votes
1 answer
676 views

is it possible to filter checkout cart collection magento 2?

Actually i want to filter the checkout cart collection using custom attributes values using this link $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $quoteId = $objectManager-&...
Hitesh Balpande's user avatar
3 votes
0 answers
443 views

Magento 2.3 collection factory not exist

I use magento 2.3 and I can't see collectionFactory created in generated folder or inject to any class. ModelFactory can create normally. There are my code: Model file: <?php namespace Lights\...
the light's user avatar
  • 728
4 votes
4 answers
973 views

How to call save method in collection instance

I was appeared Magento 2 Associate developer certification exam, in that I got the below tricky question, but I don't know the concept and answer of the question. can you have an idea regarding the ...
senthil's user avatar
  • 1,739
2 votes
3 answers
9k 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 ...
Ashar Riaz's user avatar
  • 1,035
2 votes
1 answer
801 views

Best seller items in category magento 2

I have used below code to filter products by category id. $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $catalog_ids = 4; $productCollection = $_objectManager- >create('...
Jafar Pinjar's user avatar
  • 1,961

1
3 4
5
6 7
11