By In Magento 2

Limit free shipping by total weight – Magento 2

Magento 2 basic installation have three ‘offline’ shipping methods included: free shipping, flat rate and table rates.

They are called ‘offline’ because all shipping rates will be calculated using offline resources, basically only ‘table rates’ use advanced math and calculate fee according to provided CSV file.

Magento 2 also comes with four more shipping methods, dimensional weight methods (DHL, FedEx, UPS, USPS), that use external data to calculate how much customers have to pay for shipping.

 

Most popular  ‘offline’ shipping method among customers is ‘free shipping’, everybody loves free shipping, they will pay just for products and there is no extra fee – great right 🙂

Now comes tricky part, free shipping has only one condition which is

One of our customers that have store based on Magento 2 platform noticed that among all stuff that they sell there are products that are heavy or bulky to be sent via regular shipping, however price of those products was high enough to enable free shipping. So his request was quite simple, to limit free shipping option to 120 lbs. of total cart weight, if items in cart go above that value ‘free shipping’ shouldn’t be available.

So we made small module that extend Magento ‘free shipping’ module by adding more field in Shipping Methods > Free Shipping tab, where admin can enter maximal weight for free shipping.

Here is the screen shot of admin section after we deployed our mini module:

Magento 2 - Free shipping method settings

Magento 2 – Free shipping method settings

Module simply extend condition that is located in Carrier file (notice that we added Rewrite folder to remeber that module overwrites core module):

app\code\Smdesign\FreeShipping\Model\Rewrite\Carrier\Freeshipping.php

so we now have too conditions that need to be fulfilled: Minimum Order Amount and 

Instead copying parts of code and explaining every  line I decided to provide module as package (please backup everything before deploy it) and I am quite sure that you will manage to grasp code in it.

 

Unpack archive into your Magento 2 installation root folder, navigate to /bin folder or use path in command line (as you like) and run commands in console:

magento module:enable Smdesign_FreeShipping

magento setup:upgrade

Please don’t hesitate to post comments I appreciate your feedback, any idea, improvement or reported bug/issue are more than welcome.

I am new to Magento 2 but eager to learn it and hope that will be able to post about it often.

Cheers 🙂



 

 

Read more

By In Magento

Extending CreareSEO module

CreareSEO module is really great addition to any Magento 1 store and helps a lot with basic SEO related settings, latest version can be found on GitHub. Among bunch of useful features there is also a ‘Twitter Cards and Open Graph’ section that will automatically add Twitter card and OG meta tags to product details page.

In few simple steps we will extend that feature to category page as well.

First we will add one more filed in section ‘Twitter Cards and Open Graph’ that we will use for Facebook app ID. Open in editor file: app/code/community/Creare/CreareSeoCore/etc/system.xml
and add code from attached file ‘system-update’. Be sure to copy code within section, we want to keep module consistency and usability.

Save file and open Magento admin: System->CreareSEO->General Settings tab, you will see a new field that we named ‘Facebook app id‘. Enter your Facebook app id and hit save button.

On our luck CreareSEO use base package and default theme so it is easy to find and edit layout files.
So next would be XML layout file:
app/design/frontend/base/default/layout/creareseo.xml

We will add this line:

< block type="core/template" name="ccreareseo.category.social" ifconfig="creareseocore/social/enabled" template="creareseo/social/category-social.phtml" />

For sections (for both sections reference is ‘head’):
catalog_category_layered
and:
catalog_category_view

After that we will create a template file by name ‘category-social.phtml’ and copy it into folder:
app/design/frontend/base/default/template/creareseo/social/

To save you some time I will provide template with code. Since code in template is quite simple so there is no need to explain it line by line. Of course code can be changed as it suit you and additional marks can be added. If you find something interesting you are more than welcome to shear it in comments 🙂

 

Finally we will use Facebook app ID on product details template too (it is missing for some reason), open template:
app/design/frontend/base/default/template/creareseo/social/social.phtml

and add this line:
< meta property=”fb:app_id” content=”< ? php echo Mage::getStoreConfig(‘creareseocore/social/facebookappid’) ? >” />

Once you save everything, clear Magento cache and test your page using official FB tool:
https://developers.facebook.com/tools/debug/

Read more

By In Magento

Lesti FPC on Nexcess Magento Hosting

Step by step guide how to setup Lesti FPC on Nexcess Magento Hosting.

Nexcess offers a full range of Magento hosting options, starting from servers with Shared Resource, Dedicated Servers up to platform specialized for Magento Enterprise.
While packages have a bit higher price that can be easily compensate with quality of service that they provide and technical support which is familiar with Magento platform.

Most interesting thing are Redis Cache & Memcached features that are available even on sheared servers, SIP 200
is lowest package that include those two. So if you have SIP 200 or better package there is no reason why you wouldn’t use all resources that you have and speed up your site significantly.

To make things clear if you have very slow Magento site with bad code and lot of 3rd party modules than there is no trick that would help you. You should simply reconsider fixing those issues first before start any work on optimization and fine tuning.

First step would be to create ticket on Nexcess help-desk and ask them to to create a redis instance on your server for Magento. They usually recommend a combination of Redis for caching and memcached for sessions storage, to get these two often accessed things into memory instead of on disk for performance. Also they can set up a memcached instance for sessions and put those settings in local.xml as well.

Once you have everything setup connect via SSH and test Redis with this command:
redis-cli -ping
if all is good you will get PONG

To flush Redis you can use this command, be sure to replace customer_specific_name in stirng with your customer name:
redis-cli -s /var/tmp/redis-multi_customer_specific_name_cache.sock FLUSHALL
if all is good you will get message OK

Once we have all this set it is time to install Gordon Lesti fpc module (thank you very much Gordon for all your help), it can be downloaded from: https://github.com/GordonLesti/Lesti_Fpc

Unpack zip file and in configuration file:
\app\etc\modules\Lesti_Fpc.xml
change value for ‘active’ node from ‘true’ to ‘false’

From file ‘fpc.xml.sample’ create config faile that we will use ‘fpc.xml’ and open it in editor.
In same time open ‘local.xml’ file of your Magento, Nexcess support already added Redis configuration code into it.
Copy those settings in ‘fpc.xml’ file by replacing code that start with: < ! -- example for redis -- >

Save file with changes and proceed with installation of FPC module via FTP. Once all files are copied open module config file and change value for ‘active’ node from ‘false’ to ‘true’ to enable module. Login into Magento back-end and navigate to System->Configuration->System and under tab ‘Lesti FPC’ you will find module settings. If you are using RWD theme module will work with default settings, in case that you have custom theme some additional directions are needed.
After you complete setup go to System->Cache Managemnt and enable FPC caching, than you can test site speed using your favorite tool.

Cheers !

Read more