35

我想在成功设置 Magento 后安装示例数据。在 Magento2 中安装 Magento 后安装示例数据的过程是什么?

4

16 回答 16

41

下载样本数据:

php bin/magento sampledata:deploy

然后安装示例数据:

php bin/magento setup:upgrade

http://m4s0.com/install-magento-2-with-sample-data/

于 2015-12-09T19:22:51.523 回答
38
  1. 安装示例数据模块:

    • 使用作曲家:

      1. 将依赖项添加到composer.json

        composer require magento/module-bundle-sample-data magento/module-widget-sample-data magento/module-theme-sample-data magento/module-catalog-sample-data magento/module-customer-sample-data magento/module-cms-sample-data  magento/module-catalog-rule-sample-data magento/module-sales-rule-sample-data magento/module-review-sample-data magento/module-tax-sample-data magento/module-sales-sample-data magento/module-grouped-product-sample-data magento/module-downloadable-sample-data magento/module-msrp-sample-data magento/module-configurable-sample-data magento/module-product-links-sample-data magento/module-wishlist-sample-data magento/module-swatches-sample-data magento/sample-data-media magento/module-offline-shipping-sample-data --no-update
        
      2. 跑:

        composer update
        
    • 使用 magento:

      1. 部署示例数据:

        bin/magento sampledata:deploy
        
  2. 启用示例数据模块(这很重要!):

    bin/magento module:enable Magento_CustomerSampleData Magento_MsrpSampleData Magento_CatalogSampleData Magento_DownloadableSampleData Magento_OfflineShippingSampleData Magento_BundleSampleData Magento_ConfigurableSampleData Magento_ThemeSampleData Magento_ProductLinksSampleData Magento_ReviewSampleData Magento_CatalogRuleSampleData Magento_SwatchesSampleData Magento_GroupedProductSampleData Magento_TaxSampleData Magento_CmsSampleData Magento_SalesRuleSampleData Magento_SalesSampleData Magento_WidgetSampleData Magento_WishlistSampleData
    
  3. 删除旧文件:

    rm -rf var/cache/* var/page_cache/* var/generation/*
    
  4. 升级 magento 文件:

    bin/magento setup:upgrade
    
  5. 重新编译文件:

    bin/magento setup:di:compile
    
  6. 重新索引:

    bin/magento indexer:reindex
    
  7. 部署静态内容:

    bin/magento setup:static-content:deploy
    
于 2016-07-07T08:15:20.283 回答
9

您可以使用命令行通过转到 magento 2 根文件夹来安装示例数据。然后,

  1. 下载样本数据:$php bin/magento sampledata:deploy

  2. 安装示例数据:$php bin/magento setup:upgrade

参考:http ://devdocs.magento.com/guides/v2.0/install-gde/install/sample-data-after-magento.html

于 2015-12-05T12:07:43.743 回答
3

首先安装magento2。只需运行以下命令即可安装示例数据。

1)转到您的安装目录:

root@prince:/var/www/html/magento2#

2)之后,运行此命令

php bin/magento sampledata:deploy

3)现在登录到magentocommerce以获取用户名和密码

https://www.magentocommerce.com/magento-connect/customer/account/login/

4)转到开发人员->安全密钥,生成新密钥或使用现有密钥

-> 使用公钥作为用户名私钥作为密码

5) 现在运行此命令重新编译代码、升级数据库和清除缓存

php bin/magento setup:upgrade

现在运行此命令进行重新索引

php bin/magento indexer:reindex

最后授予文件和文件夹的权限

于 2016-12-26T07:26:44.267 回答
3

我刚刚经历了这个:如果你在 github 上的默认开发分支上,示例数据将不起作用。而是抓住主人。

git clone -b master https://github.com/magento/magento2.git

然后使用示例数据包更新您的 composer.json。从文档->

在许可证之前添加“最低稳定性”:“测试版”,现在看起来像

"name": "magento/project-community-edition",
"description": "Magento project (Community Edition)",
"type": "project",
"minimum-stability": "beta",
"version": "1.0.0-beta",
"license": [
    "OSL-3.0",
    "AFL-3.0"
],

composer config repositories.magento composer http://packages.magento.com然后运行composer require magento/sample-data:~1.0.0-beta

现在您的示例数据包已安装,更新您的数据库

<path to Magento 2 bin dir>/magento setup:upgrade

<path to Magento 2 bin dir>/magento sampledata:install <your Magento administrator user name>

于 2015-09-22T17:13:28.100 回答
2

你已经解决了吗?如果没有,请参阅:http ://devdocs.magento.com/guides/v2.0/install-gde/install/sample-data.html#instgde-install-sample-enable-after

于 2015-09-20T09:29:00.310 回答
2

这很简单,作曲家可以使用,只需要进入根目录并

使用以下命令下载示例数据:

php bin/magento sampledata:deploy

然后安装示例数据

php bin/magento setup:upgrade

如果网站上没有显示数据,您还可以清理缓存或重新编制索引。

使用以下命令: php bin/magneto indexer:reindex

于 2019-10-09T16:18:39.557 回答
2

您可以使用此替代方法:

composer config repositories.0 composer https://repo.magento.com

接着:

bin/magento sampledata:deploy

系统将提示您输入用户名/密码:使用您的 magento 市场帐户中的public_key / private_key

于 2017-12-26T01:15:53.900 回答
1

从 Composer 存储库部署示例数据

在 Magento 根目录中,运行以下命令:

# bin/magento sampledata:deploy

该命令从模块的composer.json文件的建议部分收集依赖项,建议安装示例数据

要在不使用 Magento CLI 的情况下从 Magento Composer 存储库部署示例数据:

在根composer.json文件的require部分中指定示例数据包,例如:

{
"require": {
    ...
    "magento/module-catalog-sample-data": "{version}",
    "magento/module-configurable-sample-data": "{version}",
    "magento/module-cms-sample-data": "{version}",
    "magento/module-sales-sample-data": "{version}"
    ....
}

}

其中version是包的版本;它应该对应于 Magento 实例的版本。

于 2016-08-15T21:37:37.707 回答
1

Magento 设置后的 Magento 示例数据安装(在主分支中工作 -解决方案适用于旧版本 - 测试版)。

命令的工作方式类似于

<path to Magento 2 bin dir>php magento setup:upgrade

<path to Magento 2 bin dir>php magento sampledata:install <your Magento administrator user name>

命令就像不工作。

<path to Magento 2 bin dir>/magento setup:upgrade

<path to Magento 2 bin dir>/magento sampledata:install <your Magento administrator user name>
于 2015-09-24T06:43:34.307 回答
0

试试这个。

在终端中运行以下命令

php bin/magento sampledata:deploy //在magento2中部署样本数据

php bin/magento setup:upgrade //升级模块并运行安装文件

php bin/magento setup:di:compile //编译文件

php bin/magento indexer:reindex //索引平面表和产品价格

php bin/magento setup:static-content:deploy // 重新生成静态文件

授予 Var 文件夹 777 的完全权限。

在浏览器中加载网站

于 2017-05-09T05:24:13.037 回答
0

如果您的 composer.json 文件中没有 Magento 存储库,则上述代码将不起作用。尝试运行

作曲家配置 repositories.magento 作曲家https://repo.magento.com

在您的 composer.json 文件中添加一个 magento 存储库,然后运行

php magento 示例数据:部署

于 2016-12-07T15:52:32.670 回答
0

在我使用这种方法安装示例数据之前,我为此苦苦挣扎了很久。我是什么工具;)

https://devdocs.magento.com/guides/v2.2/install-gde/install/sample-data-after-clone.html

于 2018-06-20T19:53:52.680 回答
0

以下将解决您的问题

确保您在 Magento 安装目录中并且您具有写入权限:然后逐步运行

php bin/magento sampledata:deploy

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

php bin/magento setup:upgrade

于 2018-07-03T21:21:00.067 回答
0

我们可以在 Magento2 安装后使用终端安装示例数据。我们需要运行以下命令。

  1. php bin/magento c:c
  2. php bin/magento 示例数据:部署
  3. php bin/magento s:up
  4. php bin/magento s:d:c
  5. php bin/magento s:s:d
  6. sudo chmod -R 777 var var/* pub pub/static/* 生成 生成/*

有关更多信息,请查看如何在 Magento2 中安装示例数据

于 2021-01-28T15:38:22.910 回答
0

Magento2 is very easy to install.

Step 1-: download the source code from github.

Step 2-: Extract the source code on your web root.

$ unzip magento2.zip 

Step 3-: Install dependencies via composer command.

$ cd /var/www/html/magento2/   
$ composer install

Step 4-: Set the require permission and ownership.

$ sudo chmod -R 775 /var/www/html/magento2/
$ sudo chown -R www-data:www-data /var/www/html/magento2/

Magento2 instance is ready to install. Open the web browser, use you server ip or localhost.

于 2016-04-19T07:43:14.500 回答