Skip to content

collection

Auto Added by WPeMatico

Magento 2: Get Product Collection With Multiple SKUs Filter

I’m trying to get product collection with multiple skus filter, don’t know what I’m missing or doing wrong: $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $productCollectionFactory = $objectManager->create(‘MagentoCatalogModelResourceModelProductCollectionFactory’); $collection = $productCollectionFactory->create(); $collection->addAttributeToSelect([‘name’,’sku’]); $collection->addAttributeToFilter(‘sku’, [‘in’ => [‘IS-OB-2165′,’TM-VIVO-Y15’]]); $collection->setPageSize(3); foreach ($collection as $product) { print_r($product->getName()); }

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/Productlist/ProductlistCollection.php File function – $collection = $simiObjectManager->create(‘MagentoCatalogModelProduct’)->getCollection() ->addAttributeToSelect($simiObjectManager->get(‘MagentoCatalogModelConfig’) ->getProductAttributes()) ->addMinimalPrice() ->addFinalPrice() ->addTaxPercents() ->addUrlRewrite(); when we… Read More »Magento 2 SimiCart – Magento 2 Mobile App Builder

Pager not work in my custom collection?

I have a custom collection for ordered products for a customer. $connection = $this->resourceConnection->getConnection(MagentoFrameworkAppResourceConnection::DEFAULT_CONNECTION); $customerSession = $this->customerSession->create(); if ($customerSession->isLoggedIn()) { $customerId = $customerSession->getId(); $result1 = $connection->fetchAll(‘SELECT distinct(product_id) FROM `sales_order_item` as soi INNER join sales_order as so on so.entity_id=soi.order_id WHERE so.customer_id… Read More »Pager not work in my custom collection?

Magento 2 RightJoin Query have extra Join condition

I’m using a query to provide data for my UI component. $catalogrule = $this->getTable(‘catalogrule’); $this->getSelect() ->reset(Zend_Db_Select::COLUMNS) ->columns([‘s_id’, ‘created_at’, ‘created_by’, ‘sync_status’, ‘error’]) ->joinRight( [‘p’ =>$catalogrule], ‘main_table.magento_id = p.rule_id’, [‘entity_id’ => ‘p.rule_id’,’name’ => ‘p.name’] ) ->group(‘p.rule_id’); parent::_renderFiltersBefore(); but when I print this… Read More »Magento 2 RightJoin Query have extra Join condition

Magento 2 override product list page collection

I am trying to override the product collection of the product list page (category page). (Just for testing locally) I am editing the vendor/magento/module-catalog/Block/Product/ListProduct.php file and the _beforeToHtml() method: protected function _beforeToHtml() { $collection = $this->_getProductCollection(); $collection->addAttributeToSelect(‘*’); $collection->addAttributeToFilter(‘manufacturer’, array(‘eq’ =>… Read More »Magento 2 override product list page collection

How to filter customer collection by custom field added by db_schema xml file to customer_entity table in Magento 2?

I added ‘custom_field’ to ‘customer_entity’ table by using ‘db_schema.xml’ file and need to save ‘some value’ in it then I wanted to filter the collection by ‘custom_field’ value. How can I achieve this ? When I use the below code.… Read More »How to filter customer collection by custom field added by db_schema xml file to customer_entity table in Magento 2?