Skip to main content

Posts

Showing posts from July, 2020

Magento 2 add images in knockout files

If you want to add a dynamic image from the theme or module’s web/images folder, You can be assigned images using the knockout template with ease. Simply call the function in src of your image tag, require.toUrl(‘web/images’) Keep the image in web/images/logo.png location of your theme or module. <img data-bind="attr: { src: require.toUrl('images/pawan.png') }" /> Now simply add above one line in .html template to display the image on your page.  Using this method, Your images search for the theme web/images folder. If you want to display Images from specific Module’s Web folder: If you have images in the module web folder in your theme or Custom module, app/design/frontend/{Vendor}/{themename}/Magento_Checkout/web/images/logo.png You have to add module name before image path, <img data-bind="attr: { src: require.toUrl('Magento_Checkout/images/logo.png') }" /> When you see the front page, your images have taken a path from the pub/static

Magento 2 checkout - Update shipping methods after change of city, address line and telephone fields

When we  need to trigger the call that updates the shipping methods on the checkout page when the city, address lines, telephone and email fields change. Just like when the shipping methods are updated when the postcode, country and province fields change. We need to try below steps in custom shipping module as described follows and its working fine for me: Pawan/Customshipping/view/frontend/requirejs-config.js var config = {     "map": {         "*": {             "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/flatrate": "Pawan_ Customshipping /js/model/shipping-rates-validation-rules/flatrate",         }     } }; Pawan/Customshipping /view/frontend/web/js/model/shipping-rates-validation-rules/flatrate.js define([], function () {     'use strict';     return {         /**          * @return {Object}          */         getRules: function () {             return {                 'country_id': {                

How to Add Magento 2 Sort by Price for Low to High & High to Low Options and name A-Z & Z-A etc sort dropdown

The store design and its navigation must be in such a way that makes it easier for the shopper to find the exact required product and make the shopping process comfortable and enjoyable.  Navigation can be made easier and hence improve the shopping experience by offering custom sorting options. The default Magento 2 offers sorting by position, product name, and price  A price-sensitive customer may save some clicks by starting with the cheapest products. On the other hand, customers who have a high standard for quality may quickly find their most desired products by sampling from high prices to low prices. To provide such feature in Magento 2 and serve both the type of price-sensitive customers, you can add Magento 2 sort by price for low to high & high to low options. Some people can sort by names A-Z or Z-A, position low to high high to low like this we can improve sales to our site and user can easily find products for implementing this fallow given steps to implement sorting Ad

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