Sohaib's Tech Blog

Something for every one

Magento 2.x: Required parameter ‘theme_dir’ was not passed — 2017

Magento 2.x: Required parameter ‘theme_dir’ was not passed

This error message appears in Magento 2 when you deleted a theme directory and the theme registry reminds in the database.

To fix this issue you need to go to app/design/frontend and check which themes you have installed.
Then go to the database and execute the following command:

SELECT * FROM theme;

Check what is the extra theme in that table and remove the registry.

Clear cache and that should be it.

Advertisements
Magento2 Set Anchor to YES in all Categories — 2017

Magento2 Set Anchor to YES in all Categories

I am assuming you’ve PHPMYADMIN , not going in detail as to how you install that and all that crap

First identify the attribute id of the is_anchor attribute:

SELECT * FROM eav_attribute where attribute_code = 'is_anchor';

I get attribute 54 as my query not sure what you will get as that’s all depends on your environment

Now let’s run a Query to update all category to Anchor YES

UPDATE catalog_category_entity_int set value = 1 where attribute_id = 54;

TADA !!!!!!

Magento2 Varnish 503 Backend Fetch Failed Problem **SOLVED — 2016

Magento2 Varnish 503 Backend Fetch Failed Problem **SOLVED

I’ve  M2.10 , Varnish , Redis and Nginx intalled and using Php7.08 with installed after doing a lot of research I wasn’t able to find a solution for this.

I was moving around attributes from groups to un-assigned group in Magento 2.10, I notice I was having issue with Varnish and the error was Varnish 503 Backend Fetch Failed.

The problem was in “clean_cache_by_tags” function in Magento. I think it’s an error clearing the cache in php7 & magento2.

Quick fix is to turn off block_html cache. Everything works in Php 5.6x but in PHP7.08 its causing a lot of problem.

Should I downgrade or stay upgraded is the question ?

After installing php5.6 it appears everything seems to be working fine

 

How to use Gmail or Amazon SES with Magento — 2016

How to use Gmail or Amazon SES with Magento

Let’s configure Gmail or Amazon SES with Magento2 or Magento 1 or any other php application, basically will configure our server in a way so any php application will then use local php mail but email will route with any SMTP provider.

Step 1

apt-get install msmtp -y
apt-get install libxml-xpath-perl  -y
nano ~/.msmtprc

Now will edit or add .msmtprc file

account gmail
tls on
tls_certcheck off
auth on
host smtp.gmail.com
port 587
user yourusername@gmail.com
from youruser@gmail.com
password Yourpasswordhere

Let’s change permission and give proper ownership and copy the file to appropriate location

chmod 600 ~/.msmtprc
cp -p ~/.msmtprc /etc/.msmtp_php
chown www-data:www-data /etc/.msmtp_php

Now will edit php.ini file so we can tell sendmail to use our Gmail SMTP

I am using PHP 7 so my location is different then your’s probably, if you are using Ubuntu or any flavor you can simply use

locate php.ini

 

nano /etc/php/7.0/fpm/php.ini
nano /etc/php/7.0/cli/php.ini

Now will edit sendmail in php.ini

sendmail_path = "/usr/bin/msmtp -C /etc/.msmtp_php --logfile /var/log/msmtp.log -a gmail -t"

Lastly will make sure to have our log file

touch /var/log/msmtp.log
chown www-data:www-data /var/log/msmtp.log

Now goto your Magento2 admin or Magento admin or any PHP Application to try to sendmail email it will use Gmail or Amazon SES to send emails out, you just need to modify your msmtp file

Magento 2.01 Broken CSS and Magento 2.01 Admin Page not found — 2016
How I got my Gtmetrix.com Score to 1.98s — 2015

How I got my Gtmetrix.com Score to 1.98s

My last project was very challenging where I was told to optimize Magento Site, Customer was using a dedicated server where I’ve to optimize not only Magento but also Optimize & Speed up the server, Took me some real time and hard work. I am happy Yayyyyy.

I don’t want to get in details as far as server configuration but I achieve 1.98s load time

Magento which was loading in 22s to 15s , I got it down to 1.98s

I’ve setup the following

APC
Memcached
Nginx with Pagespeed

If you need any assistance from me speeding up your Magento, Drop me a line, I charge flat $1,000 and trust me it takes a lot of time and effort, Oh yea client was using Amazon Cloudfront CDN but then he switch to Akamai CDN which is the TOP Dawg in CDN world I am here to assist.

So do you want to speed up your magento store ?

Magento Defer JavaScript — 2015

Magento Defer JavaScript

How I achieve 2.8s Load time in Magento as compare to 10s using the following

In order to have Defer Javascript, Please change the following files page.xml, my page.xml is stored at

/home/domain/public_html/app/design/frontend/base/default/layout/page.xml
<block type="page/html_head" name="head" as="head">
<action method="addJs">prototype/prototype.js<params>async</params></action>
<action method="addJs">lib/ccard.js<params>async</params></action>
<action method="addJs">prototype/validation.js<params>async</params></action>
<action method="addJs">scriptaculous/builder.js<params>async</params></action>
<action method="addJs">scriptaculous/effects.js<params>async</params></action>
<action method="addJs">scriptaculous/dragdrop.js<params>async</params></action>
<action method="addJs">scriptaculous/controls.js<params>async</params></action>
<action method="addJs">scriptaculous/slider.js<params>async</params></action>
<action method="addJs">varien/js.js<params>async</params></action>
<action method="addJs">varien/form.js<params>async</params></action>
<action method="addJs">varien/menu.js<params>async</params></action>
<action method="addJs">mage/translate.js<params>async</params></action>
<action method="addJs">mage/cookies.js<params>async</params></action>
GTmetrix
GTmetrix
WebServer with Percona Google Pagespeed — 2014

WebServer with Percona Google Pagespeed

Today : I would like to share how you setup a fast Webs Server with MYSQL .

In this tutorial you don’t really need any control panel and waste your money, like Cpanel or this and that, I am not discouraging any one but I cant stand them.

We are setting up the following
NGINX
Google Page Speed
Percona *MYSQL Database
Memcahed
PHPmyadmin

No Apache so NO MORE .htaccess file…

In my environment, I have a 15GB Server with 200GB SSD RAID 10

Oh yea, before I forget I have a Ubuntu 12.04 Precise.

Assuming you are a ROOT user.

apt-get update
apt-get install memcached php5-cli php5-fpm php5-mysql php5-curl php5-gd php5-imagick php5-mcrypt php5-memcached php5-imap

Simply and easy and you are done.

Now let’s create a user and public_html

adduser sohaib

Go to

cd /home/sohaib/

Create public_html or whatever you wanted to call your HOME directory, regarding setting up nginx configuration How to Nginx Google Pagespeed

How to fix Magento 1.8 Admin Blank Page — 2013

How to fix Magento 1.8 Admin Blank Page

Ok, on to the solution::

So, you left compilation mode on, but cannot reach the backend to switch it off. If you have SSH access, you are in luck.

Step 1: Check current compilation status

$ php -f shell/compiler.php -- state
Compiler Status:          Enabled
Compilation State:        Compiled
Collected Files Count:    6042
Compiled Scopes Count:    4
  • Disable Magento compilation:
    $ php -f shell/compiler.php -- disable
    Compiler include path disabled
  • Clear all compiled files
    $ php -f shell/compiler.php -- clear
    Compilation successfully cleared
  • Ensure that compiler is disabled now by checking its status:
    $ php -f shell/compiler.php -- state
    Compiler Status:          Disabled
    Compilation State:        Not Compiled
    Collected Files Count:    0
    Compiled Scopes Count:    0

Step 2: Clear all cache in Magento

Via FTP or SSH

Magento upgrade from 1.7 to 1.8 — 2013

Magento upgrade from 1.7 to 1.8

Take a Code backup as well as DB backup before upgrade. Use SSH to upgrade. Follow below steps to upgrade..

Open command terminal.
Go to your Magento directory by cd command like cd /var/www/yourmagento/ & run below commands step by step…
chmod -R 777 lib/PEAR
chmod 550 pear
./pear mage-setup
perl -pi -e 's/rn/n/g' pear
./pear upgrade -f magento-core/Mage_All_Latest-stable
chmod 550 ./mage
./mage mage-setup . (* notice the dot after mage-setup command)
./mage sync
./mage list-upgrades
./mage upgrade-all –force

Open config.xml and change the statement SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;
Empty your cache,sessions
Visit your site. It will take some time to loading depends on your data. Normally for 2 GB it will take 2 hours.