CentOS 7迁移Magento 1.9.x到Mangento 2

Magento 2安装页面

Magento 2出来也挺久时间了,市场上的反应有部分人觉得它很慢,这可能与硬件设备的要求有关,也有部分人觉得不好用。不管怎样,事物总是向前发展的,Magento 2必将逐步取代Magento 1.9.x,这只是时间问题,也有消息称从今年11月起官方将可能不再对1.9.x的版本支持。Alan已经很久没有对Magento进行研究了,今天抽空对一个站点作迁移的尝试,在这里记录下来过程和问题和大家分享。

Read More

Magento 2 命令行

在Magento 2中可通过命令行来进行相当一部分的操作,如清除缓存、重新索引页面等。进入安装路径的bin目录下,输入php magento –list即可看到相对应的命令:

Usage:
 command [options] [arguments]

Options:
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question

Available commands:
 help                                      Displays help for a command
 list                                      Lists commands
admin
 admin:user:create                         Creates an administrator
 admin:user:unlock                         Unlock Admin Account
cache
 cache:clean                               Cleans cache type(s)
 cache:disable                             Disables cache type(s)
 cache:enable                              Enables cache type(s)
 cache:flush                               Flushes cache storage used by cache type(s)
 cache:status                              Checks cache status
catalog
 catalog:images:resize                     Creates resized product images
cron
 cron:run                                  Runs jobs by schedule
customer
 customer:hash:upgrade                     Upgrade customer's hash according to the latest algorithm
deploy
 deploy:mode:set                           Set application mode.
 deploy:mode:show                          Displays current application mode.
dev
 dev:source-theme:deploy                   Collects and publishes source files for theme.
 dev:tests:run                             Runs tests
 dev:urn-catalog:generate                  Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml.
 dev:xml:convert                           Converts XML file using XSL style sheets
i18n
 i18n:collect-phrases                      Discovers phrases in the codebase
 i18n:pack                                 Saves language package
 i18n:uninstall                            Uninstalls language packages
indexer
 indexer:info                              Shows allowed Indexers
 indexer:reindex                           Reindexes Data
 indexer:set-mode                          Sets index mode type
 indexer:show-mode                         Shows Index Mode
 indexer:status                            Shows status of Indexer
info
 info:adminuri                             Displays the Magento Admin URI
 info:backups:list                         Prints list of available backup files
 info:currency:list                        Displays the list of available currencies
 info:dependencies:show-framework          Shows number of dependencies on Magento framework
 info:dependencies:show-modules            Shows number of dependencies between modules
 info:dependencies:show-modules-circular   Shows number of circular dependencies between modules
 info:language:list                        Displays the list of available language locales
 info:timezone:list                        Displays the list of available timezones
maintenance
 maintenance:allow-ips                     Sets maintenance mode exempt IPs
 maintenance:disable                       Disables maintenance mode
 maintenance:enable                        Enables maintenance mode
 maintenance:status                        Displays maintenance mode status
module
 module:disable                            Disables specified modules
 module:enable                             Enables specified modules
 module:status                             Displays status of modules
 module:uninstall                          Uninstalls modules installed by composer
sampledata
 sampledata:deploy                         Deploy sample data modules
 sampledata:remove                         Remove all sample data packages from composer.json
 sampledata:reset                          Reset all sample data modules for re-installation
setup
 setup:backup                              Takes backup of Magento Application code base, media and database
 setup:config:set                          Creates or modifies the deployment configuration
 setup:cron:run                            Runs cron job scheduled for setup application
 setup:db-data:upgrade                     Installs and upgrades data in the DB
 setup:db-schema:upgrade                   Installs and upgrades the DB schema
 setup:db:status                           Checks if DB schema or data requires upgrade
 setup:di:compile                          Generates DI configuration and all non-existing interceptors and factories
 setup:di:compile-multi-tenant             Generates all non-existing proxies and factories, and pre-compile class definitions, inheritance information and plugin definitions
 setup:install                             Installs the Magento application
 setup:performance:generate-fixtures       Generates fixtures
 setup:rollback                            Rolls back Magento Application codebase, media and database
 setup:static-content:deploy               Deploys static view files
 setup:store-config:set                    Installs the store configuration
 setup:uninstall                           Uninstalls the Magento application
 setup:upgrade                             Upgrades the Magento application, DB data, and schema
theme
 theme:uninstall                           Uninstalls theme

如查看缓存状态,仅需输入php magento cache:status

php magento cache:status

Magento2尝鲜

Magento已在进行Magento 2的开发,测试版已放出,下载地址为https://github.com/magento/magento2,安装方法请参照:

[New Update] How to install Magento 2.0: Clear & detail-oriented guide to set up easily

其中composer在安装过程中,会要求翻墙才能连接到相应的服务器去下载资源,这里不进行赘述。整个安装页面进行了优化,相比1.x.x而言要更加高大上了,以下是安装完成后后台的登录页面:

Magento 2登录页面

以下是后台页面显示效果,可以看出整个界面做了比较大的调整:

Magento 2后台页面

当然最大的更改是整个代码的目录结构,如我们熟悉的skin目录在Magento2中被完全去除,主题都放到了app\design\frontend\Magento下等等。

常见问题

1.Mac使用XAMPP php替代系统(~/.bash_profile)
Magento 2最新版本要求使用PHP 7,如果所使用的XAMPP集成的是PHP 5请去Apache Friends下载最新版本

export XAMPP_HOME=/Applications/XAMPP
export PATH=${XAMPP_HOME}/bin:${PATH}
export PATH

2.缺少ext-intl的问题
切换到Magento根目录执行composer install时,有可能会出现多种报错,像mcrypt之类的问题通过常见问题1中的方法即可解决,但对于intl缺失的问题,需要单独进行安装,报错内容如下:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-intl * is missing from your system. Install or enable PHP's intl extension.

解决步骤如下:

# 下载最新版Autoconf
http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
# 解压后进行该目录执行安装
./configure
make
sudo make install
# 根据XAMPP的PHP版本到PHP官网下载对应版本的源码,如Alan现在使用的是7.1.4
http://jp2.php.net/distributions/php-7.1.4.tar.gz
# 解压进入ext/intl文件夹,执行如下命令来安装
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install
# 安装完成后重启XAMPP的Apache服务,用以下命令查看是否安装成功
php -m | grep intl 
# 再次进入Magento 2的根目录执行以下命令来进行依赖包的安装
composer install