Git: HEAD, Detached HEAD & Reset HEAD

What is Git HEAD? “HEAD” is an alias for your current working commit. It’s the latest commit of your currently checked out branch. If you checkout a another branch then HEAD will be the latest commit in that particular branch. Check Git HEAD status The following shows that the working directory is the tip of … Read more

jQuery: Uncaught TypeError: url.indexOf is not a function

I got the “url.indexOf and e.indexOf is not a function” errors on my website. I got this error after my upgrade to my Magento webshop, but this error can happen on any website with a jQuery version upgrade. Error: Uncaught TypeError: e.indexOf is not a function at w.fn.load (jquery-3.3.1.min.js:2:82468) at caribbean-montego-mntgo-shell:1483:19 at Object.execCb (require.js:1696:33) at … Read more

Magento 2: Clean Fastly or Varnish Cache by Cache Tag Programmatically

This article shows how you can clean Fastly Cache or Varnish Cache by cache tags in Magento. Fastly has an observer that listens to the event clean_cache_by_tags. vendor/fastly/magento2/etc/events.xml (github) <event name="clean_cache_by_tags"> <observer name="flush_fastly_cdn" instance="Fastly\Cdn\Observer\InvalidateVarnishObserver"/> </event> The \Fastly\Cdn\Observer\InvalidateVarnishObserver class further calls the \Fastly\Cdn\Model\PurgeCache::sendPurgeRequest($pattern) method which finally cleans the Fastly Cache utilizing \Fastly\Cdn\Model\Api. Magento’s Cache_Invalidate module has … Read more

Magento 2: Clean Cache by Cache Tags Programmatically

This article shows how you can clean cache by cache tags in Magento. use Magento\Framework\App\CacheInterface; class YourClassName { /** * @var CacheInterface */ protected $cache; /** … * @param CacheInterface $cache */ public function __construct( … CacheInterface $cache ) { … $this->cache = $cache; } /** * Clean Cache by Cache Tag * * @param … Read more

Magento 2: Enable/Disable Cache Programmatically

This article shows how you can enable or disable Magento Cache Programmatically. For this purpose, we will be using \Magento\Framework\App\Cache\Manager class. use Magento\Framework\App\Cache\Manager as CacheManager; class YourClassName { /** * @var CacheManager */ protected $cacheManager; /** … * @param CacheManager $cacheManager */ public function __construct( … CacheManager $cacheManager ) { … $this->cacheManager = $cacheManager; } … Read more

Magento 2: Get, Clean and Flush Cache Programmatically

This article shows how you can get the list of all Cache Types in Magento and how you can clean and flush those Cache Types in Magento. Cache Types in Magento Magento has the following cache types: Configuration (config) Commerce collects configuration from all modules, merges it, and saves the merged result to the cache. … Read more

Magento 2: Search Repository using SearchCriteriaBuilder, Filter & FilterGroup

This article shows how we can search Magento Repositories using SearchCriteriaBuilder that implements SearchCriteriaInterface. An example is provided of how we can perform search on Product repository in Magento. Similarly, we can search for other entities like Category, Customer, Order, Invoice, CMS Page, CMS Block, etc. We can add different conditions to build custom search … Read more

MySQL: Drop All Triggers from a Database

I got the error “Trigger already exists” error while I was re-importing a MySQL database. A solution to this problem is to create DROP queries for all the Triggers of the database. SELECT Concat('DROP TRIGGER ', Trigger_Name, ';') FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA = 'your_database_name'; This will print out the DROP statements for all the triggers. … Read more