Skip to main content

Posts

Magetno 2 get the products collection filter by attributes with or condition

how to get product collection with filters? I'm use magento 2 . So i'm trying to get in product collection with filter multiple attributes with or condition for custom search use below product collection object if your wring any blocks if not use object manager and create product collection object use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollection; $productcollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection'); $collection = $this->_productCollection                                     ->create()                                     ->addFieldToSelect('*')                                     ->addAttributeToFilter(                                     array(                                             array('attribute' => 'name', array('like' => '%'.$queryString.'%')),                                             array('attribu

Magetno 2 add Reorder link in my order view order page

Copy this file into your custom theme  public_html\vendor\magento\module-sales\view\frontend\templates\order\info.phtml public_html\app\design\frontend\Infortis\ultimo\Magento_Sales\templates\order\info.phtml add below code  <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance();  $productCollectionFactory = $objectManager->get('\Magento\Sales\Block\Order\Recent'); //print_r($productCollectionFactory->getReorderUrl($_order)); ?> <div class="buttons-set">         <?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>                                 <a href="#" data-post='<?php /* @escapeNotVerified */ echo                                 $this->helper(\Magento\Framework\Data\Helper\PostHelper::class)                                     ->getPostData($productCollectionFactory->getReorderUrl($_order))                                 ?>&#

foreign keys List in MySQL database

The query below returns the foreign key constraints defined in the user databases (schemas). select concat(fks.constraint_schema, '.', fks.table_name) as foreign_table,        '->' as rel,        concat(fks.unique_constraint_schema, '.', fks.referenced_table_name)               as primary_table,        fks.constraint_name,        group_concat(kcu.column_name             order by position_in_unique_constraint separator ', ')               as fk_columns from information_schema.referential_constraints fks join information_schema.key_column_usage kcu      on fks.constraint_schema = kcu.table_schema      and fks.table_name = kcu.table_name      and fks.constraint_name = kcu.constraint_name -- where fks.constraint_schema = 'Database Name' group by fks.constraint_schema,          fks.table_name,          fks.unique_constraint_schema,          fks.referenced_table_name,          fks.constraint_name order by fks.constraint_schema,          fks.table_na

My Account display only after login

If Want to know how to display "My Account" only after customer LogIn. After LogOut it will again be hidden on the same place. The customer_logged_* layout handles used in M1 were removed in M2. Below is a small plugin using a method similar to what's used in core for adding/removing the "Register" top link in Magento\Customer\Block\Account\RegisterLink Pawan/Myaccount/Plugin/Link.php namespace Vendor\Module\Plugin; use Magento\Customer\Model\Context; class Link {     protected $httpContext;     public function __construct(         \Magento\Framework\App\Http\Context $context     ) {         $this->httpContext = $context;     }     public function afterToHtml(\Magento\Customer\Block\Account\Link $subject, $result)     {         if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {             return $result;         }         return '';     } } Pawan/Myaccount /etc/frontend/di.xml <?xml version="1.0"

Magento 2 UI Component Grid Explanation

1) layout file inside Company/Module/view/adminhtml/layout/routerid_controller_action.xml define grid as uiComponent with: 2) uiComponent is defined in Company/Module/view/adminhtml/ui_component/listing_name.xml file. File name must be the same as uiComponent name used in layout file. The structure of the file may seem pretty complex at first sight but as always these are some repeating nodes. To make it simple lets slice it. Main node of the component file is <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">. It is fixed and I believe it requires namespace location attribute. Next there are typically 4 nodes inside <listing /> node: <argument />, <dataSource />, <container /> and <columns />. This is however not a strict setup as <argument /> node might be duplicated to provide more configuration or <container /> as

EAV Entity type in Magento 2

Magento 2 divides entity into 8 types as below: customer – Entity Id = 1 customer_address – Entity Id = 2 catalog_category – Entity Id = 3 catalog – Entity Id = 4 order – Entity Id = 5 invoice – Entity Id = 6 creditmemo – Entity Id = 7 shipment – Entity Id = 8 (You can see in the eav_entity_type table )

Magento 2: Show price for out of stock configurable products

 If want to show price for out of stock configurable product price you need to check  vendor/magento/module-configurable-product/Pricing/Price/ConfigurablePriceResolver.php Find function on line number 61 public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product) Before Editing ::: public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)     {        $price = null;        foreach ($this->lowestPriceOptionsProvider->getProducts($product) as $subProduct) {             $productPrice = $this->priceResolver->resolvePrice($subProduct);             $price = isset($price) ? min($price, $productPrice) : $productPrice;         }        return (float)$price; } After Editing ::: public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $product)     {         $price = null;               $assPrice=array();         foreach ($this->configurable->getUsedProducts($pr