Windows10安装Magento2的示例数据

安装可选的示例数据模块

Magento样本数据简介

Magento样本数据提供了基于Luma主题的店面,该主题配备了产品,类别,客户注册等。它的功能就像Magento店面一样,您可以使用Magento Admin操作价格,库存和促销定价规则。

您可以在安装Magento软件之前或之后安装样本数据。完成示例数据后,可以将其删除,也可以按照删除示例数据模块或更新示例数据中的说明进行新安装

目前无法卸载示例数据。我们建议您仅使用示例数据来了解Magento的工作原理。避免在安装样本数据的系统中进行任何开发。

您可以在安装Magento软件之前或之后安装样本数据。完成示例数据后,可以将其删除,也可以按照删除示例数据模块或更新示例数据中的说明进行新安装。 
您可以通过以下任何方式安装可选的示例数据:

您可以通过以下任何方式安装可选的示例数据:

安装方法描述所需的技能水平
使用Composer运行magento sampledata:deploy以修改Magento的根composer.json以启用示例数据模块。需要Composer知识并访问Magento文件系统。
克隆存储库克隆Magento 2存储库和示例数据存储库,然后将它们链接在一起。仅供参与者使用。其他人都应该使用上述方法之一。

如果您的Magento应用程序设置为生产模式,请不要安装示例数据。首先切换到开发者模式。在生产模式下安装样本数据失败。

php bin/magento setup:upgrade 

您需要进行身份验证才能完成操作。

授权错误

可能会显示以下身份验证错误:

[Composer\Downloader\TransportException]
The 'https://repo.magento.com/packages.json' URL required authentication.
You must be using the interactive console to authenticate

如果显示错误,请更改到Magento安装目录并运行composer update,这将提示您输入身份验证密钥

安装Magento软件

样本数据安装完成后,使用命令行安装Magento软件。

下面是在Windos10上安装示例数据的例子

1.切换为开发者模式

D:\www\20190627mgt2>php bin/magento deploy:mode:show 
Current application mode: default. (Note: Environment variables may override this value.)
D:\www\20190627mgt2>php bin/magento deploy:mode:set developer
Enabled developer mode.

2. 命令行安装示例数据

php bin/magento sampledata:deploy
D:\www\20190618mgt227>php bin/magento sampledata:deploy
./composer.json has been updated
Loading composer repositories with package information

    Authentication required (repo.magento.com):
      Username: 56f942d7cb2b84dc71416a14c7de96e2
      Password:
Do you want to store credentials for repo.magento.com in D:/www/20190618mgt227/var/composer_home/auth.json ? [Yn] y
Updating dependencies (including require-dev)
Package operations: 20 installs, 0 updates, 0 removals
  - Installing magento/module-catalog-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-bundle-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-customer-sample-data (100.2.0): Downloading (100%)
  - Installing magento/sample-data-media (100.2.0): Downloading (100%)
  - Installing magento/module-theme-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-cms-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-widget-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-catalog-rule-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-sales-rule-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-downloadable-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-wishlist-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-review-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-tax-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-msrp-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-product-links-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-grouped-product-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-offline-shipping-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-swatches-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-configurable-sample-data (100.2.0): Downloading (100%)
  - Installing magento/module-sales-sample-data (100.2.1): Downloading (100%)
<warning>Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.</warning>
Writing lock file
Generating autoload files
安装示例数据过程 截图

3. 由于我 先安装magento后按照示例数据,所以必须运行以下命令来更新<magento_root>文件夹中的数据库和架构:

php bin/magento setup:upgrade

更新<magento_root>文件夹中的数据库和架构 1

您需要进行身份验证才能完成操作,如果之前在输入身份验证时候,保存了数据记录,那么现在就不需要输入。


更新<magento_root>文件夹中的数据库和架构 2

这个时候,看见这个数据则代表操作完成。
再刷新网站,如果是下面的结果,则表示示例数据安装成功。

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用 * 标注