Category Archives: PHP

How to fix Magento 2.4.x sort by position category products issue

This is very common problem which is being faced by all of magento 2 stores. Even Magento support saying it is fixed but still it is not working old stores which have customized plugins. So simple fix it, go to file location vendor/magento/module-catalog-search/Model/ResourceModel/Fulltext/Collection.php We have to update function _renderFiltersBefore. See below function /** * @inheritdoc… Read More »

How to run wordpress blog from subfolder

Common problem when your main website running different platform like java and you need to install wordpress blog with same domain but as subfolder. For example: Website url https://www.{domain}.com running on Java nginx server. Now you want to run wordpress in php apache server as sub folder like https://www.{domain}.com/blog. So you can add following nginx… Read More »

How to Install Magento on windows host

Let follow below post, how to install Magento 2.4 locally on Windows using XAMPP server. This tutorial is targeted on current Magento 2.4 users and also users who are completely new to Magento. Now, let’s get started! Part 1: Install and configure XAMPP Step 1: Download XAMPP Download link: https://www.apachefriends.org/download.html We recommend installing XAMPP with PHP… Read More »

How to create own custom API in Magento 2

The REST API documentation published on the Magento 2 Developer Documentation website describes the REST APIs that are available on the latest release of Magento 2.  This documentation is generated from the code base using Swagger and represents the state of the code at the time the documentation was generated. Swagger displays a list of service names. Click on a service… Read More »

how to block requests with specific string using .htaccess in apache

These days common problem of hacking of website by hacker with scrips. They always use some common method or string to hack it. Now you can prevent these requests by adding some simple .htaccess rules. You could send a 403 Forbidden (access denied) in case -admin is requested : RewriteEngine On RewriteCond %{REQUEST_URI} ^/(.*?)admin RewriteRule ^(.*)$ – [F,L]  … Read More »

PHP how to sort array with user defined keys

Many times, we need to do sort array with some user defined keys. So we can use pre defined php function to make it easier.  We can array_flip function to achieve it, array_flip — Exchanges all keys with their associated values in an array.  array_flip() returns an array in flip order, i.e. keys from array become values and values from array become keys. Note… Read More »

How to redirect non www or non https url to www and https

This is very common problem to everyone to redirect non www urls to www with https. You can follow simple .htaccess rules to implement it. RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] The only real difference here is that first we redirect from non-WWW to… Read More »