Imagine you need to run a Magento 2 installation from a sub-directory, using Nginx, but you don’t have ownership of the main site, just the sub-directory.
So we are not talking here about store view codes, redirect loops etc, we are talking about this:
Server 1 : www.website.domain
/shop/ -> IP Server 2 Server 2 : www.website.domain/shop/
The problem
Magento 2 has differences in terms of application structure and directories with Magento 1. (see image below)
How to run Magento 2 from a subdirectory. Magento version comparison
The most important difference here is the endpoint. While in Magento 1 the endpoint is the index file of the Magento installation, “[magento]/index.php”, in Magento 2, the endpoint is inside the pub folder, “/[magento]/pub/index.php”.
Therefore all request for each store-view will go through this folder.
Create Subfolders
For each Base URL you have to add a sub-folder at the end, so if you need to have www.website.domain/shop You will need to create :
mkdir ~/[magento]/pub/shop
Create Symlinks
Then you need to create symlinks inside the sub-folder just created to the static content folders, like ‘media’, ‘static’… This is necessary because Magento 2 will go to gather this information inside the reference given by the endpoint, that is inside the “pub/shop” folder.
For example:
ln -s ../media media
ln -s ../static static
For the index.php, instead of symlink. You need to copy it and modify the relative path for the app/bootstrap script. Like follows:
This Magento 2 tutorial looks at the Magento 2 full page cache (FPC). The FPC is a key performance feature in Magento 2, but differs significantly from the Magento 1 FPC.
One of the most notable aspects of FPC in Magento 2 is that it is now a standard feature in the Community Edition (CE). In Magento 1 FPC was an Enterprise Edition (EE) feature only, which meant that CE users had to buy a module to get this sort of functionality.
The other equally notable aspect of Magento 2’s FPC is that Varnish integration is available in FPC with only minimal configuration, which means that caching is at the heart of Magento 2 rather than an afterthought.
Changes at a glance
Magento 1
Magento 2
EE only feature
CE and EE feature
Varnish distance from FPC
Varnish integrated
Built-in option only
Built-in and Varnish options
Built-in recommended for production
Varnish recommended for production
Hole punching for private content
Placeholders and AJAX/local storage for private content
Javascript used as a workaround to deliver private content
Use the $.mage.__(”) function when adding a string:
1
$.mage.__(‘<string>’);
If your string contains a variable:
1
$.mage.__(‘How to translate %1’).replace(‘%1’,yourVariable);
The 5 steps I mention above is the shortest process for you to Translate a String by Code in Magento 2. With this guide, you can manage the String by Code in Magento 2 easily. Every store has a String by Code in Magento 2 with many attributes.
Related products同样显示在产品详细页面中,与Upsells不同,Related products默认会显示在右侧边栏。这些产品被用来设计推荐给用户该产品之外的配套产品。比如用户在浏览笔记本电脑的时候,在右侧的Related products中可能会显示笔记本电脑鼠标,笔记本电脑屏幕保护膜等产品。