## 安装magento:
可以参考 :[https://www.kancloud.cn/zouhongzhao/magento2-in-action/628424](https://www.kancloud.cn/zouhongzhao/magento2-in-action/628424)
*****
## 配置paypal :
不需要安装插件,直接利用magento后台配置,要申请paypal商业账号,创建商业账号sandbox(us), 得到 商家用户和客户用户 来测试支付和收入。
![](https://img.kancloud.cn/c5/a8/c5a82364e30aa73a768af1f495d18991_694x410.png)
参考资料:
1,国外资料
[https://www.mageplaza.com/kb/how-to-configure-paypal-express-checkout-payment-method-magento-2.html](https://www.mageplaza.com/kb/how-to-configure-paypal-express-checkout-payment-method-magento-2.html)
2,国内资料
[https://www.kancloud.cn/zouhongzhao/magento2-in-action/699199](https://www.kancloud.cn/zouhongzhao/magento2-in-action/699199)
*****
## 配置 stripe 信用卡支付 (选):
https://stripe.com/docs/plugins/magento-2
[Installing the Magento 2 Module | Stripe Documentation](https://stripe.com/docs/plugins/magento-2/install#manual)
![](https://img.kancloud.cn/35/a4/35a4577520169b463172a8db58eb2e95_779x639.png)
配置好,可以测试:
![](https://img.kancloud.cn/07/df/07dffda3a6b378074d02cb37c03c0968_1095x476.png)
支付成功,stripe配置是相对容易:
![](https://img.kancloud.cn/65/31/653149983edb1016c3696b83df9afa58_736x424.png)
*****
## 安装mageplaza方的插件,
记得安装 core:
https://github.com/mageplaza/module-core
如果国内环境出现问题,解决方案:
![](https://img.kancloud.cn/c5/41/c541a363b5777bbacc9796268babf58b_651x195.png)
参考:[https://github.com/mageplaza/module-core/issues/26](https://github.com/mageplaza/module-core/issues/26)
```
// 修改这里的代码则可以:
**if($params\['extension'\] == 'Mageplaza\_Blog'){**
** $result\['success'\] = true;**
** $result\['key'\] = 'BLOG-XXXXXXXXXXXXXXXX';** //解决验证问题,key在mageplaza后台订单有
**}**
```
*****
## https的配置 :
参考:[https://www.kancloud.cn/zouhongzhao/magento2-in-action/647798](https://www.kancloud.cn/zouhongzhao/magento2-in-action/647798)
*****
*****
## SMTP邮件功能
magento需要配置smtp才能发邮件,例如Amazon云的邮件服务,mailgun等
需安装插件: [https://www.mageplaza.com/magento-2-smtp/](https://www.mageplaza.com/magento-2-smtp/)
![](https://img.kancloud.cn/14/e1/14e1b97a69c7f0953e8e8784592f9f52_695x277.png)
邮件发信地址配置好:
![](https://img.kancloud.cn/25/57/25573678ecf3b5c240cee5df4c90bc16_1292x612.png)
测试发信成功:
![](https://img.kancloud.cn/fa/0c/fa0c76150df237ba5a29a38395d002f2_816x621.png)
*****
## 后台配置全部检查一次:(重要)
![](https://img.kancloud.cn/92/54/92543dee63f7c8c4ddb995c49e395c0f_612x724.png)
*****
# 开发前准备:
**1. 开启调试功能 debug**
1.1 ,切换到 develop模式
~~~
php bin/magento deploy:mode:set developer
~~~
1.2,前端页面提示 layout+container:
![](https://img.kancloud.cn/3e/d1/3ed1539105b0fedfb916d77ed56d9621_1523x555.png)
*****
1.3,debug后台模块位置:
https://bbs.mallol.cn/question/m2-open-foreground-template-debugging-path/
*****
**2. 怎样查看Log:**
参考:2.1,https://www.kancloud.cn/zouhongzhao/magento2-in-action/681201
2.2,https://devdocs.magento.com/guides/v2.3/config-guide/log/custom-logger-handler.html
```
~~~
查看log,debug的地方:
主要看debug.log/exception.log
如果还没有可靠的信息的话,就看apache/nginx里配置的error log。
~~~
```
**3,基本知识学习:**
https://www.kancloud.cn/zouhongzhao/magento2-in-action (国内)
https://www.mageplaza.com/ (国外)
**4, restful api的使用:**
[REST API reference | Adobe Commerce Developer Guide (magento.com)](https://devdocs.magento.com/redoc/2.3/)
参考: https://www.kancloud.cn/zouhongzhao/magento2-in-action/861578
~~~
//通过rest/V1/integration/admin/token登录后台生成token
$userData = array("username" => "zou", "password" => "zou用户的密码");
$ch = curl_init("http://magento2demo.texiaoyao.cn/rest/V1/integration/admin/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
$ch = curl_init("http://magento2demo.texiaoyao.cn/rest/V1/customers/1");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
$result = curl_exec($ch);
var_dump($result);
~~~
返回结果:
~~~
string(641) "{"id":1,"group_id":1,"default_shipping":"1","created_at":"2018-06-11 01:09:31","updated_at":"2018-11-30 05:01:44","created_in":"Default Store View","email":"zouhongzhao@126.com","firstname":"zou","lastname":"hongzhao","store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"\u6e56\u5317","region":"\u6e56\u5317","region_id":0},"region_id":0,"country_id":"CN","street":["\u9ad8\u65b0\u5927\u9053"],"telephone":"1510232345","postcode":"430000","city":"\u6b66\u6c49","firstname":"zou","lastname":"hongzhao","default_shipping":true}],"disable_auto_group_change":0,"extension_attributes":{"is_subscribed":false}}"
~~~
*****
## 万能命令,修复问题:
~~~
php bin/magento maintenance:enable
rm -rf var/di/* && rm -rf var/generation/* && rm -rf var/cache/* && rm -rf var/page_cache/* && rm -rf var/view_preprocessed/* && rm -rf pub/static/* && rm -rf generated/* && mkdir var/di
php bin/magento setup:upgrade && php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f && php bin/magento indexer:reindex && php bin/magento maintenance:disable && php bin/magento cache:clean && php bin/magento cache:flush
~~~
## 服务器配置:
建议:4核16g =》同时250人/min =》达到基本要求