Skip to main content

Posts

Magento 2.1.6 Product Grid page count and record count issue when programmatically adding filter using different methods

I have found a method that works. It seems that the Category view, regardless of a filter being applied or not, will  ALWAYS  use the Catalog Search module. Knowing that, we can override the following class to add a custom filter. Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection   But it's not that simple, first we have to create a custom filter in an xml document. Here are the steps: Step 1 Create a search_request.xml file in  Company/RegionManager/etc/search_request.xml . For my example I used the following code, you can replace any instance of deal_active with your custom attribute. Including the $deal_active$ <?xml version="1.0"?> <requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:noNamespaceSchemaLocation="urn:magento:framework:Search/etc/search_request.xsd">  <request query="catalog_view_container" index="catalogsearch_fulltext">         <queries>     ...

Magento How do I enable free shipping in backend only (for order entry)

1>  Override or your custom shipping method file        app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php       or        app/code/local/ YourCompany/NewModule/Model/Carrier/ShippingMethod.php 2> You can find      public function collectRates(Mage_Shipping_Model_Rate_Request $request)   And add below two code in function          if (!Mage::app()->getStore()->isAdmin())) {             return false;         }      after below these two lines         if (!$this->getConfigFlag('active')) {             return false;         } And set to active in backend You can place the code in local if you dont want to overwrite the core This should work

If you want discount sorting in product list page(category page)

1> First need to create discount attribute for products. 2> After creation that copy  app/code/core/Mage/Catalog/Mo del/Resource/Product/collection.php in local folder app/code/local/Mage/Catalog/Mo del/Resource/Product/collection.php open the file find below bit of code around 1572      if ($attribute == 'price' && $storeId != 0) {             $this->addPriceData();             $this->getSelect()->order("price_index.min_price {$dir}");             return $this;         } after that Add below code if ($attribute == 'discount') {             //determine the discount percent value             $this->addExpressionAttributeT oSelect('discount', '(({{price}} - special_price) / {{price}})', array('price'));             ...

magento2 get all customizable option from products

create test file in root directory and place the below code excute it with domain/test.php <?php     //THis is test     echo '<pre>';     error_reporting(0);     ini_set('display_errors', 1);     use Magento\Framework\App\Bootstrap;     include('app/bootstrap.php');     $bootstrap = Bootstrap::create(BP, $_SERVER);     $objectManager = $bootstrap->getObjectManager();     $url = \Magento\Framework\App\ObjectManager::getInstance();     $storeManager = $url->get('\Magento\Store\Model\StoreManagerInterface');     $websiteId = $storeManager->getWebsite()->getWebsiteId();     $state = $objectManager->get('\Magento\Framework\App\State');     $state->setAreaCode('frontend');     //$product = $objectManager->get('\Magento\Catalog\Model\Product')->load('2331');     $productCollection = $objectM...

Create custom option programmatically in magento2

Create test.php file magento2 root directory and copy below code <?php echo '<pre>'; error_reporting(0); ini_set('display_errors', 1); use Magento\Framework\App\Bootstrap; include('app/bootstrap.php'); $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $url = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $url->get('\Magento\Store\Model\StoreManagerInterface'); $websiteId = $storeManager->getWebsite()->getWebsiteId(); $state = $objectManager->get('\Magento\Framework\App\State'); $state->setAreaCode('frontend'); $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/importmissingorders.log'); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); //die("here"); $productId = 2; $product = $objectManager->create('\Magento\Catalog\Model\Product')->load($productId); $values = [          ...

magento 1.9 to magento 2.X migration process using migration tool

According to the official Magento documentation, migration to the Magento 2 consists of four different stages: Theme Migration Extension Migration Customizations Data Migration Theme Migration Magento 2 introduces new methodologies and technologies for delivering enhanced shopping and store experience to the merchants and users. Developers can take advantages of new ways of creating awesome Magento 2 themes or modify the current ones to make them compatible with the Magento 2 standards. You should keep in mind that you cannot directly migrate your Magento 1 theme to Magento 2. You have to create a new theme for Magento 2 and make it responsive for the best user experience.  If you wish to avoid all this hassle, buy and install a Magento 2 theme from the Magento Marketplace or from other reputed sources. Extension Migration Extensions are essential components that provide new features and extend the functionalities of your Magento store. The next step in Ma...