1.静态文件有版本号,静态文件不能读取,页面无法显示。如下图:

解决方案:其实URL里的版本号对于magento来说是合法的,这是因为我们缺少了一个文件\pub\static\.htaccess;导致路由重写不能成功进行,或其 .htaccess 书写错误导致的;处理方法如下:

创建并写入.htaccess 文件到pub/static

#正则路由
RewriteRule ^version.+?/(.+)$ $1 [L]
#重定向目录
##==========
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l RewriteRule .* ../static.php?resource=$0 [L]

  

2,安装分销插件 Amasty_Affiliate 报错如下:

Notice: Undefined index: id in /home/staging/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php on line xx
---------------
问题是因为我在system.xml中有不正确的标签ID匹配。
参考下方语法:
<tab>customtab</tab>
#改为
<tab>custom_tab</tab>

  我通过添加定义如下:解决问题

<tab id="amasty_affiliate" translate="label" sortOrder="2000">
<label>Amasty Affiliate</label>
</tab>
<tab>amasty_affiliate</tab>

  

  

3,%7B%7BMEDIA_URL%7D%7D 解码:{{MEDIA_URL}} 错误连接问题。

问题如下:

解决方案:

CONTENT > Design > Configuration > Edit > HTML Head,

<link  rel="stylesheet" type="text/css"  media="all" href="{{MEDIA_URL}}styles.css" />

修改:

<link  rel="stylesheet" type="text/css"  media="all" href="/pub/media/styles.css" />

  

4.报错: (Magento\Framework\Exception\LocalizedException): Invalid Document Element 'add', attribute 'title':

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid Document
Element 'add', attribute 'title':

解决方案 :通常这种错误表示代码中的XML文件无效;只需要修复它们以与XSD相关联。

5.重建索引错误
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5580-299-10-137-5580' for key 'PRIMARY', query was: INSERT INTO `catalog_product_index_eav_temp` (`entity_id`,`attribute_id`,`store_id`,`value`,`source_id`) VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?

  解决方案:
  查询记录》找到 value_id 清除;

  查询
    SELECT * FROM catalog_product_entity_varchar where attribute_id = 299 and entity_id = 5580;

  结果:删除:delete FROM catalog_product_entity_varchar where value_id = 58753;

6. 解决 - 前端requireJs 引入外部有依赖Jquery的 modal 插件

require(["jquery"],function($){
/**
* body add class
*/
$("body").addClass('page-measurements'); require(
["jquery",'Mc_Size/plugins/jquery.modal.min'],
function ($,modal) {
//。。。。。
})})

  

7.解决Setup:Upgrade 更新数据表不成功。

  在更新了UpdateSchema.php后,修改Module.xml 的版本后。再执行 php bin/magento setup:upgrade 命令时,发生数据库没有更新的问题。

  解决问题的原理是:UpdateSchema.php 代码里 有写数据库表存在时,不创建表。所以不能被更新 。

  解决办法:一是修改 UpdateSchema.php 代码,让更新时如愿以偿(具体请看相关的语法。)。二是删除表后,修改版本号了,再执行更新命令 (简单粗暴).。

8.php bin/magento setup:static-content:deploy -f  生成静态不成功。
  

/../vendor/magento/framework/Filesystem/Directory/Read.php(210): Megento\Framework\Filesystem\Driver\File->fileGetContents('/...',NULL,NULL);

问题原因: Zip文件无法读取;

经过命令:

php bin/magento setup:static-content:deploy -f -vvv

打印详细过程,找到对应目录;修复某些模块的差异文件。

问题得到解决。

9.错误 :There has been an error processing your request Exception printing is disabled by default for security reasons.

  

  •   解决:
  • 首先找出文件位置:  find 指定目录 -name 错误号
  • 按对应报错解决即可。(如何需要内容查找参考: grep -r 查询内容 指定目录)

10. 大部分后台的配置 为操作数据表 core_config_data 内。当发现在后台更改配置不成功时,更改Store view 即可解决。

  Store view 位置为:Stores->settings->Configuration->左上角下拉菜单;

  #注意:如果没有 “Stores->settings->Configuration->左上角下拉菜单”  ;则在Stores->settings->Configuration->General->Enable Single-Store Mode=No;即可;

10. 在订单 View 里的商品列表。当我们要修改订单列表的商品时,会遇到如如下代码:

   -1.1 , $block->getItemHtml($item); ( \Magento\Sales\Block\Items\AbstractItems ) ;

    -1.1.1 ,方法调用 getItemRenderer 获取别名为 renderer.list 的子Block;

   /** @var \Magento\Framework\View\Element\RendererList $rendererList */
$rendererList = $this->getRendererListName() ? $this->getLayout()->getBlock(
$this->getRendererListName()
) : $this->getChildBlock(
'renderer.list'
);

      -1.1.1.1 ,子block定义如下:

 <block class="Magento\Framework\View\Element\RendererList" name="sales.order.items.renderers" as="renderer.list"/>

        - 1.1.1.1.1 , getItemRenderer 调用了  $renderer = $rendererList->getRenderer($type, self::DEFAULT_TYPE, $template);

  类 Magento\Framework\View\Element\RendererList 继承自 所有块的基类( abstract class AbstractBlock )。RendererList 使用了 setTemplate 设置了模板;

  结果:产品的.PHTML 在sales_order_item_renderers.xml.XML 里。

11, 如何启用或禁用静态内容签名?

  1, Stores» → «Configuration» 3 → «Advanced» → «Developer» → «Static Files Settings» → «Sign Static Files 设置为YES\NO;

  2, 更新 core_config_data 数据表的PATH = "dev/static/sign" 设置value为0\1 。删除缓存更新后完成。

12.根据产品ID查询对应标题:

            $_connection = $this->mc_get_obj(\Magento\Framework\App\ResourceConnection::class);//get class
$db_connection = $_connection->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);//connection
$category = $db_connection->fetchAll('select * from '.'`catalog_product_entity_varchar` '.'left join '.'`eav_attribute` '.'on '.
'`eav_attribute`.'.'`attribute_id`='.'`catalog_product_entity_varchar`.'.'`attribute_id` '.
'where '.'`eav_attribute`.'.'`attribute_code`='.'"name" '.'and '. '`catalog_product_entity_varchar`.'.'`entity_id`='.$vi['product_id']); var_dump($category[0]['value']);die;

13.找不到magento 2 block 的 template 属性:如:<block class="Amasty\Affiliate\Block\Account\Setting" name="amasty_affiliate.account.setting" cacheable="false"></block>;真实目录以编程方式获取为:app/code/Amasty/Affiliate/view/frontend/templates/account/setting.phtml

14,magento 2 开启打印全部数据库查询日志:

 以 app/etc/di.xml
<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\Quiet"/> # 替换如下:(无Quiet 类直接添加即可;) <!--#fixme Add xu-->
<preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\File"/>
<type name="Magento\Framework\DB\Logger\File">
<arguments>
<argument name="logAllQueries" xsi:type="boolean">true</argument>
</arguments>
</type>
<!--end xu-->

15, 切换数据库后,后台无法登陆( ERR_TOO_MANY_REDIRECTS );其中原因是cookie数据库缓存;使用数据库查询:select * from core_config_data where path like 'web/cookie%'; 查看其中的 web/cookie/cookie_domain 的 value 为更改后的域名“.m223:8890”(magento 2.2.3前面需要加个点)。

  bin/magento config:set web/cookie/cookie_domain xxxx.com

16,切换数据库后,如主题已经不再用提示错误:Required parameter 'theme_dir' was not passed 。

  a,转到 theme 表,然后删除创建的主题的条目。
  b,转到您的core_config_data表并搜索 theme ,您将获得路径记录,把 design/theme/theme_id,替换其中的 theme 表主题ID。

17,MAGENTO 2主题不显示在前端时该怎么办?( 如:切换数据库后,拷贝主题代码后; )

    a, 第一步:检测主题 / 添加 “Theme” 表中;
    b, 第二步:找到该行,更新该列 Type 属性从 1 改为 0;

    c, 第三步:php bin/magento setup:upgrade --keep-generated && php bin/magento setup:static-content:deploy -f && php bin/magento cache:clean && php bin/magento cache:flush

18,无法将产品添加到购物车  这个问题比较复杂,我在谷歌浏览器问题存在。切换Safari 浏览器 加入购物车正常;

19, 更换SSL,无论你是从HTTP切换为HTTPS,或是HTTPS切换到HTTP;当网站可以访问,无论如何清理缴存&重建索引,静态内容的加载连接始终是相反的HTTP协议时。请检查数据 core_config_data 表,path 使用前端的网络安全 (web/secure/use_in_frontend) 的值是否为 0(关闭HTTPS)或 1 (开启HTTPS) ;试着修改它,然后更新缓存。 我通过这个办法修复了; 执行命令(bin/magento config:set web/secure/use_in_frontend 0|1);常见SSL问题

20, Unknown or bad timezone (时区未知或错误):删除core_config_data 表 path 列为 general 为 Null 的行; 我在 magento.stackexchange.com 有正确回答。

21,当发生不可以加入购物车时,尝试一下是否可以用于登录; 都不可以?那么试过用了很长的时间寻找问题是什么?最后解决的办法是使用ip地址作为域名是可以了。这并不算一个解决办法,但是也记录一下;

22,【非一定要解决】 Unable to send the cookie. Maximum number of cookies would be exceeded. 无法发送Cookie。将超过Cookie的最大数量; 参考

23, Warning: SessionHandler::read(): Unable to clear session lock record in ..vendor/magento/framework/Session/SaveHandler/Native.php on line 22 
Session Handler 处理查看函数无法工作;最好的解决办法是配置redis;

24,使用 Cpanel 安装Mangento2 时,php版本已经修改为正确的版本,但仍然不能composer install。 原因是ocmposer 默认了php的版本。
      解决办法:
       重新下载 composer.phar : wget https://getcomposer.org/download/1.9.0/composer.phar ; 下载完成以后执行 php <path>/composer.phar install .

25,-------

——————

======== 注意事项

  1. 当要 替换xml <block> 的 class 和 template 时,使用 referenceBlock + DI class 映射即可;应用于2.2.x以上;

      <referenceBlock name="checkout.cart.form" template="包_模块::cart/form.phtml" />
  2. -

Magento2 常见错误 ----- 定期更新的更多相关文章

  1. SVN中的常见错误(长期更新)

    一 svn中的简写含义. A:add,新增 C:conflict,冲突 D:delete,删除 M:modify,本地已经修改 G:modify and merGed,本地文件修改并且和服务器的进行合 ...

  2. CPP相关的常见错误(更新ing)

    01.只允许在C99模式下使用 for 循环初始化申明 解决:指定下即可 gcc -o xxx -std=c99 02.

  3. Python:常见错误集锦(持续更新ing)

    初学Python,很容易与各种错误不断的遭遇.通过集锦,可以快速的找到错误的原因和解决方法. 1.IndentationError:expected an indented block 说明此处需要缩 ...

  4. python的多版本安装以及常见错误(长期更新)

    (此文长期更新)Python安装常见错误汇总 注:本教程以python3.6为基准 既然是总结安装过程中遇到的错误,就顺便记录一下我的安装过程好了. 先来列举一下安装python3.6过程中可能需要的 ...

  5. 修复 Elasticsearch 集群的常见错误和问题

    文章转载自:https://mp.weixin.qq.com/s/8nWV5b8bJyTLqSv62JdcAw 第一篇:Elasticsearch 磁盘使用率超过警戒水位线 从磁盘常见错误说下去 当客 ...

  6. 初识JAVA(二)(送给Java和安卓初学者)----常见错误

    博主接着上篇的来讲哦,以后的更新中,博主会出一些练习题,有兴趣的可以做做然后吧代码粘贴到下面,大家可以一起研究学习,一起进步,本篇文章主要讲的是: 一.常见错误 二.连接上篇一起的训练 无论是什么方向 ...

  7. ubuntu 常见错误--Could not get lock /var/lib/dpkg/lock

    ubuntu 常见错误--Could not get lock /var/lib/dpkg/lock 通过终端安装程序sudo apt-get install xxx时出错:E: Could not ...

  8. 【ubuntu 】常见错误--Could not get lock /var/lib/dpkg/lock

    ubuntu 常见错误--Could not get lock /var/lib/dpkg/lock 通过终端安装程序sudo apt-get install xxx时出错: E: Could not ...

  9. SVN常见错误和版本冲突解决

    之前在Eclipse下面误删除了svn的一些插件包,后来重装了就问题重重,在这里还是建议, Windows下SVN最好使用桌面版,在文件管理器下面更新和提交. 1.常见错误整理 #, c-format ...

随机推荐

  1. docker 学习资料收集

    Docker中文网 http://www.docker.org.cn/book/ docker镜像怎么迁移到其他的服务器 http://www.talkwithtrend.com/Question/1 ...

  2. 通过Arcpy在ArcMap工具箱中添加脚本计算面图层的起终点坐标

    关键词: Arcpy,ArcMap Toolbox, Coordinates of Polygon 需求分析: Arcmap中添加有三个图层:图层“GY乡级河道”(面图层)是全县13个乡镇全部的乡级河 ...

  3. 使用cmd查看电脑连接过的wifi密码(二)

    上次写了一个查看wifi的bat文件(https://www.cnblogs.com/feiquan/p/9823402.html),发现有个问题就没法保存到记事本,而且还要处理不同的系统语言,这次重 ...

  4. The account that is running SQL Server Setup does not have one or all of the following rights: the right to back up files and directories, the right to manage auditing and the security log and the rig

    安装SQL SERVER 是规则检查提示权限问题 运行secpol.msc,没有Debug program权限,添加即可,如果已加域则要在域策略修改,或退域安装后在加域.

  5. Java中console类的简单用法

    Java.io.Console 只能用在标准输入.输出流未被重定向的原始控制台中使用,在 Eclipse 或者其他 IDE 的控制台是用不了的. import java.io.Console; pub ...

  6. 大数据平台Lambda架构详解

    Lambda架构由Storm的作者Nathan Marz提出.旨在设计出一个能满足.实时大数据系统关键特性的架构,具有高容错.低延时和可扩展等特. Lambda架构整合离线计算和实时计算,融合不可变( ...

  7. TCP/IP及内核参数优化调优

    Linux下TCP/IP及内核参数优化有多种方式,参数配置得当可以大大提高系统的性能,也可以根据特定场景进行专门的优化,如TIME_WAIT过高,DDOS攻击等等.如下配置是写在sysctl.conf ...

  8. Node.js完整的响应html页面(包括css,js文件)

    主要思想就是任何一个静态文件也应该做响应,一个获取静态文件都应当请求来处理,这是主要思想. 同时要注意两点.第一,对于不同的文件类型,比如html,css,js,请求头里面的文件类型需要根据不同的文件 ...

  9. Linux内存管理 (8)malloc

    专题:Linux内存管理专题 关键词:malloc.brk.VMA.VM_LOCK.normal page.special page. 每章问答: malloc()函数是C函数库封装的一个核心函数,对 ...

  10. windows 下mysq安装之后的数据恢复案例

    1.进入mysql的安装目录 cd C:\Java\mysql--winx64\bin 2.以默认的账号root,无密码登录mysql默认数据库 mysql -u root mysql 3.查询表us ...