All Questions
Tagged with custom-collection or collection
1,670 questions
1
vote
0
answers
38
views
How to add several input fields per entry - admin form in Magento2? [closed]
I want to be able to edit one poll and it's answers in one admin form, and have one input field per answer. I already have my collections ready, how can I create a working admin form ?
POLLS TABLE ...
1
vote
2
answers
552
views
How to remove collection filter from Magento 1.9?
I want to add filter to grid. When I add filter to sales_billing_agreement, I got the following error.
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'store_id' in where clause is ...
3
votes
1
answer
733
views
How to get in stock product collection by category id in Magento 2.3.3?
I'm using Magento 2.3.3 with multiple websites store that uses different multiple stock sources(multi inventory) and I tried to retrieve product collection by category id like this:
public function ...
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
2
answers
1k
views
How to filter with custom field on customer grid Magento 2
I have created a custom field in the filter on the customer grid using customer_listing.xml.
Now, the issue is
How can I filter with the custom field? Where do I need to do the operation?
Please ...
0
votes
1
answer
780
views
Filter collection by config product attribute value in magento 2 programmatically
I would like to know. How can i filter collection by attributes value as I am making filter api for app. Please check below code where i am filter the collection this is working for simple products ...
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 ...
5
votes
0
answers
1k
views
Magento 2 Join other tables using SearchCriteria JoinProcessor
Has anybody been able to join another table using SearchCriteria, JoinProcessor and virtual types. I have read the documentation (https://devdocs.magento.com/guides/v2.3/extension-dev-guide/searching-...
2
votes
1
answer
56
views
How to shown all the category on home page in magento2
public function getShopCategories()
{
$objectManagerr = \Magento\Framework\App\ObjectManager::getInstance();
$categoryFactory = $objectManagerr->create('Magento\Catalog\Model\ResourceModel\...
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
2
answers
424
views
How can I get my custom news collection on frontend in magento 1.9?
I had created a custom module for the news grid and form in Magento admin. I need to create custom pages with news collection on my custom news list page and a custom news detail page. How could I get ...
2
votes
0
answers
92
views
Tree categories from products collection
If I have a collection like this:
$collection = Mage::getResourceModel('catalog/product')
->getCollection()
->addAttributeToFilter('my_custom_attribbute','my custom value');
What is the ...
2
votes
2
answers
613
views
Magento 2: How to setup layerd navigation in custom product collection?
I am trying to set a layered navigation filter on the custom cms page.
for that, I have created a 1 cms page name test with two-column with left bar.
and inside it, I have called one template file
{...
2
votes
1
answer
85
views
Cart page fatal error after creating a product collection plugin, Magento 2.3
We have a need to sometimes fetch product prices from an API for products loaded on the frontend. We figured it would be easiest to create a plugin for the collection:
<?xml version="1.0"?>
<...
1
vote
1
answer
128
views
Is product repository in Magento the optimal way to read product url
I am reading a core function in Magento 2.3, the function is
\Magento\Wishlist\Helper\Data::getProductUrl
* Retrieve URL to item Product
*
* @param \Magento\Wishlist\...
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 ...
3
votes
1
answer
634
views
Magento2 - Filter order grid by multiple order id's
I need to filter the order grid by multiple order id's. So the when i enter comma separated order ids in the id filter it should filter by these ids and give result.
1
vote
3
answers
1k
views
Magento 2 Add new column in Customer Page from data from database
I would like to ask if there is an effective way to add column in Customer's Page Grid in magento admin. I have viewed all tutorials and same problems in the web but no luck on displaying the data. I ...
0
votes
1
answer
338
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
3
answers
400
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
namespace Developer\...
1
vote
2
answers
1k
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
1
answer
556
views
Magento 1.9: Get Product details for a Customer Order
I am trying to get the product_id of each orders that the customer has ordered.
One simple way is to fetch all the orders, and for each order have a loop to get all items for each order. Which will ...
2
votes
1
answer
133
views
Magento 2.3 - limit certain categories products
We have a few categories which function like "bestsellers" categories; these categories can hold any number of products, but I'd like to show only the top four.
So I figured to create an observer ...
2
votes
1
answer
940
views
Magento 2 How to get collection in SOAP UI?
I am trying to get all SOAP api collection in SOAP UI, The initial step is wrong, Everytime it fails when I write Initial WSDL.
Initial WSDL:
https://127.0.0.1/magento/soap/all/?wsdl&services=...
0
votes
0
answers
366
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
1
answer
1k
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 ...
1
vote
0
answers
74
views
Magento 2.3 want to trace collection object
I am getting NULL in where condition of product collection query on category page. I want to trace where from NULL getting added.
how can I trace collection query. I have tried debug_backtrace() as ...
2
votes
0
answers
34
views
Get all associated categories from product collection
For a custom filter on the product collection i need to be able to get all associated categories from all products from the catalog search result. On top of that, i do not need the actual categories ...
0
votes
1
answer
33
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
0
answers
277
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
1
answer
347
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
1
answer
358
views
Magento 2: load disabled category childrens
I need to get all category children of a specific category but disabled categories too.
I have this category tree:
+ Root (ID: 2) // enabled
| + Main 1 (ID: 3) // enabled
| | + Sub 1 (ID: 4) // ...
2
votes
1
answer
460
views
How to filter collection for json data field in magento2?
Have any function or way we can directly filter json data in magento2?
like:
brand: {"product":"test","purchase":"500"}
if i want to filter more than purchased 500 times in magento2 have any easy ...
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('*')
->...
0
votes
1
answer
86
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.
1
vote
0
answers
114
views
How to filter collection and still keep the original collection in Magento 1
I've created a custom module that allows you to add custom labels on product page. So I have a collection of custom objects and I want to filter it but I want to keep the original collection too.
...
2
votes
1
answer
2k
views
Magento 2 Class of custom module Collection does not exist
I created a basic index controller that outputs the collection but for some reason I am getting the following error:
{
"0": "Class Debug\\Tool\\Model\\ResourceModel\\LoadModel\\Collection ...
1
vote
1
answer
633
views
how to filter magento 2 collection with 'or', 'and' combination?
For example, the search query is 'samsung lcd'. it can match with product name or SKU.
I have below product names.
1.samsung xyz lcd.
2.samsung lcd pack.
3.samsung mobile
4.screen lcd.
so when I ...
1
vote
0
answers
78
views
Mage GetResourceModel in specific language in magento 1.9
I am working on a module to pull inventory data into a feed. For this we use Mage::getResourceModel.
Pulling the data works alright, I just have the problem that the language changes depending on the ...
0
votes
1
answer
57
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
1
answer
761
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 ...
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 ...
0
votes
1
answer
2k
views
Magento 2 Reset Modify FROM select query
How can one modify the FROM in select query without losing the left joins innerJoin etc... ? as I have tried:
$collection->getSelect()->reset(\Zend_Db_Select::FROM)->from('table_2') but then ...
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();
$...
2
votes
2
answers
533
views
Product collection retrieval N at a time (paginated)
I want to retrieve all the products. But would like to limit it to say 100 at a time to avoid too much memory usage.
I have the collection factory injected in the constructor as
\Magento\Catalog\...
0
votes
1
answer
169
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
1
answer
1k
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
1
answer
420
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 ...