标签 magento 下的文章

更新 magento2 产品索引时,elastic search 报错 - status 429

问题:magento2.4的站点,执行 bin/magento indexer:reindex 后,elastic search 报错。内容如下:

Catalog Search index process error during indexation process:
{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"index [magento2_mazia_243_product_1_v45] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"}],"type":"cluster_block_exception","reason":"index [magento2_mazia_243_product_1_v45] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"},"status":429}

尝试:按网上说的,调整elastic search设置后就可以了:

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

参考:https://stackoverflow.com/questions/63689953/magento-2-4-reindex-issue-with-elasticsearch

为 magento2 的 static 和 media 设置 aws cloudfront 访问

需求:想将magento2的static和media配置cdn,如aws的cloudfront访问。

尝试:

  1. 分别以/static和/media为源,在cloudfront创建两个分配
  2. 如/static的分配,在“行为”中的“源请求策略名称”选择为“Managed-CORS-CustomOrigin”、“响应标头策略名称”选择为“Managed-CORS-With-Preflight”
  3. 在magento2后台中,设置static和media的网址为cloudfront的
  4. 如需调整static和media文件目录中的.htaccess内容,可适当调整

参考:

magento1.x 无法导出商品的部分属性,如价格

现象:通过magento 1.x 自带的导出商品数据功能,再在迁移后的站点里导入,商品丢失价格等部分属性。如果直接通过mysqldump导出及mysql导入整个magento站点数据表,则站点后台无法列出显示商品,“商品管理”为零。

尝试:在phpmyadmin中看到,通过mysql导入数据库内容后的部分数据表,如 catalog_product_entity_int 无数据。尝试通过phpmyadmin导入该表时,提示错误 #1062 - Duplicate entry '204-102-0' for key 'UNQ_CATALOG_PRODUCT_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID' 。很可能是因为原数据库的部分数据表有错误,无法成功导出完整的数据。

参考:https://community.magento.com/t5/Magento-2-x-Technical-Issues/How-to-add-new-products-through-magento-database/m-p/447973/highlight/true

wordpess 移到 magento1.x 的子目录

需求:如果想将wordpress站点的目录移到magento1.x的子目录,通过magento的URL来访问,应该怎么做呢?

尝试:需要修改相应的静态化规则。如nginx的,可参考这个:https://docs.ukfast.co.uk/ecommercestacks/magento/magento1/wpinsubdir.html

location ~ ^/wp/ {
        index index.php index.html index.htm;
        try_files $uri $uri/ @wphandler;
        expires 30d;

        location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
                add_header Cache-Control "public";
                add_header X-Frame-Options "SAMEORIGIN";
                expires +1y;
                try_files $uri $uri/ /get.php?$args;
        }

        location ~* /(wp-admin/|wp-login\.php) {
                  try_files $uri $uri/ @wphandler;
                  index index.html index.htm index.php;
                  fastcgi_pass replacemebackend;

                  add_header Cache-Control "no-store";
                  fastcgi_buffers 1024 4k;
                  #fastcgi_param HTTPS $my_https; # Uncomment the below for SSL offloading
                  #fastcgi_param SERVER_PORT $my_port; # Uncomment the below for SSL offloading
                  fastcgi_read_timeout 600s;
                  fastcgi_connect_timeout 600s;
                  fastcgi_index index.php;
                  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                  include fastcgi_params;
        }

        location ~* \.php$ {
                try_files $uri $uri/ =404;
                fastcgi_pass replacemebackend;
               #fastcgi_param HTTPS $my_https; # Uncomment the below for SSL offloading
               #fastcgi_param SERVER_PORT $my_port; # Uncomment the below for SSL offloading
                include fastcgi_params;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
  }

  location @wphandler {
        rewrite / /wp/index.php;
  }

magento 1.x - 使用gmail作为外部SMTP发信 - 允许安全性较低的应用访问帐号

现象:在magento 1.9里安装Magento-SMTP-Pro-Email-Extension扩展后,无法使用gmail账号发出邮件。用命令测试连接smtp服务器,提示用户名或密码不可接受。535-5.7.8 Username and Password not accepted. Learn more at https://support.google.com/mail/?p=BadCredentials b4sm2793148pga.69 - gsmtp

尝试:登录到gmail账户,设置允许安全性较低的应用访问帐号。之后再次测试,就可以了。

参考: