Magento 1.9 Paypal Guest Customer Name

A lot of people seem to have issues with this, when a guest checkout checks out via Paypal the customer name field in Magento just defaults to guest, this means whenever a guest gets an email with their order confirmation it says ‘hello guest’.

To get around this start by copying:

app/code/core/Mage/Paypal/Model/Express/Checkout.php

To:

app/code/local/Mage/Paypal/Model/Express/Checkout.php

Then find this:

protected function _prepareGuestQuote()
{
    $quote = $this->_quote;
    $quote->setCustomerId(null)
        ->setCustomerEmail($quote->getBillingAddress()->getEmail())
        ->setCustomerIsGuest(true)
        ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
    return $this;
}

Replace the above code with this:

protected function _prepareGuestQuote()
{
    $quote = $this->_quote;
    $quote->setCustomerId(null)
        ->setCustomerFirstname($quote->getBillingAddress()->getFirstname()) 
        ->setCustomerLastname($quote->getBillingAddress()->getLastname())
        ->setCustomerEmail($quote->getBillingAddress()->getEmail())
        ->setCustomerIsGuest(true)
        ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
    return $this;
}

This then gets the billing address details and adds them to the Magento quote

Redirect Old Domain to New Domain via .htaccess

When you are moving your website to a new domain name you need to ensure that you are correctly redirecting all your old pages so that you don’t loose any SEO benefits from existing links. If you fail to do it properly you will probably notice a huge decrease in traffic from organic sources.

If you have not made any changes to your overall site structure and the URL’s are staying the same just on a new domain name, you can add the following lines to your .htaccess file located at the root of your old domain:

<IfModule mod_rewrite.c>
     RewriteEngine on  
     RewriteRule ^(.*)$ https://www.newdomain.co.uk/$1 [R=301,L] 
</IfModule>

Magento 2 JS bundling

I recently found a site that had JS merging and bundling turned on, when I looked into it a little more I found that the bundling side was making the JS huge. Turning the bundling off made the JS 4 times smaller and knocked a good few seconds off the site load time.

Looking further into it I really like the idea of JS bundling but it’s got a long way to come before it can be used and widely adapted.

mysql2 search engine doesn’t exists

I kept seeing the following error in system.log

“main.ERROR: mysql2 search engine doesn’t exists. Falling back to mysql [] []”

The fix for me was to go to Stores > Configuration > Catalog > Catalog under the section “Catalog Search” you’ve probably got MySQL selected for “Search Engine” and you’ve probably got “use system value” unticked. For me ticking “use system value” made the error go away.

I did see another fix for this which was to run the following sql query “UPDATE core_config_data set value = ‘mysql’ where path=’catalog/search/engine’;”

Top 5 Modules To Speed Up Magento 2

Magento 2, it’s slow out of the box, everyone knows that and knows it’s something they have to deal with.

But there must be ways to speed it up, right?

These are the modules I recommend to help speed that most of the other articles don’t cover.

  1. WebP – jpgs and pngs are old news, the latest format of images for web is WebP. By using WebP images you get either lossless and lossy compression, typically 25% smaller than jpgs. So how do we make our jpgs and pngs in Magento into WebP files? I use this module https://github.com/yireo/Yireo_Webp2
  2. Pre Loading – it’s possible to preload your primary resources, I like this module to do that https://github.com/yireo/Yireo_LinkPreload I’ve seen some good improvements in fully loaded times with this module.
  3. Cron manager – this one doesn’t always provide a direct speed improvement but I install this on every single site I develop. The module I use is https://github.com/magemojo/m2-ce-cron it’s been proven to stop cron’s stacking up with can quite often result in performance issues.
  4. Defer JS – Magento 2’s JS files tend to be huge! I use this module https://bsscommerce.com/magento-2-defer-javascript-extension.html to defer the JS by moving the JS to the bottom of the HTML.
  5. Lazy Load images – there’s loads of modules to do this, but they all basically only load the images that are visible on screen and then load the rest as you scroll. This is the module I like for doing so https://www.weltpixel.com/magento-2-lazy-load-product-extension.html

I actually think the top 3 modules should all be included in the Magento core, especially the cron module.

Give some of the above ago and let me know if you see some good improvements.

Magento 1.9 Image file was not found

I recently came across an error after upgrading to Magento 1.9.3.10, if you navigated to category page you sometimes saw the error message “Image file was not found” The reason for seeing this error is because some products have no got an image set and the default placeholder is missing.

The easiest way to get over this issue is to go to System > Configuration > Catalog > Product Image Placeholders and set new placeholder images, my guess is that you have them missing currently?

Installing Magento 2 solely from Composer

The documentation on how to install a Magento 2 project solely using the command line is pretty limited so here are the steps I take on creating a project.

composer create-project –repository=https://repo.magento.com/ magento/project-community-edition /your/local/dir/ 

The above will install all the packages need and sticks them in your directory.

Once that has finished you then can start installing Magento 2, to do that here is an install script.

bin/magento setup:install \
–base-url=http://magento2.local \
–db-host=localhost \
–db-name=magento2 \
–db-user=root \
–db-password=mysql \
–backend-frontname=admin \
–admin-firstname=admin \
–admin-lastname=admin \
[email protected] \
–admin-user=admin \
–admin-password=admin123 \
–language=en_US \
–currency=USD \
–timezone=America/Chicago \
–use-rewrites=1