定制 swiftotter/image-import-path-fix 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

swiftotter/image-import-path-fix

Composer 安装命令:

composer require swiftotter/image-import-path-fix

包简介

N/A

README 文档

README

##Installation:

  • composer require swiftotter/image-import-path-fix
  • php bin/magento module:enable SwiftOtter_ImageImportPathFix
  • php bin/magento setup:upgrade
  • php bin/magento setup:di:compile

##Description:

Where to begin on this one? This bug fix is for Magento 2.1.2 (latest as of 1/9/17). Nginx and MySQL. Folder structure is a little different than normal, so that may account for why this bug wasn't found sooner. Nginx is pointed to pub/index.php.

Folder structure:

  • current > symlinked to: /path/to/releases/release-2
  • link
    • media
      • import
      • catalog
        • product
    • var
      • log
      • report
  • releases
    • release-1
      • app
      • pub
        • index.php
        • media > symlinked to: link/media
      • ...
      • var > symlinked to: link/var
    • release-2
      • app
      • pub
        • index.php
        • media > symlinked to: link/media
      • ...
      • var > symlinked to: link/var

Issue description:

The root issue is inconsistent handling of the pub/ folder.

Magento's initial file is pub/index.php. The cwd for this file is /path/to/releases/release-2/pub/. However, a feature of \Magento\Framework\Filesystem\Directory\ReadInterface->getAbsolutePath() is that it removes /pub from the path structure. This works well, until trying to use relative paths in combination with vanilla PHP functions, such as is_readable($relativePath).

There are two facets: the tmp directory (where the files are coming from) and the dest directory (where the files are going to). Both have unique challenges.

tmp directory:

The tmp directory comes from the "Images File Directory". Magento strips out the reference to pub/ at the end. As the media folder is inside the pub folder, it is unclear as to how to reference this folder. The patch deals with this by providing an additional lookup path.

I am not sure if this was also causing issues, but the tmp directory was relative and not absolute. This caused problems for the dest directory, so I have patched the tmp as well.

dest directory:

This was home to another inconsistency. When creating / setting the folder in \Magento\CatalogImportExport\Model\Import\Product->_getUploader, the paths are initially checked as absolute paths. However, when it is used in \Magento\Framework\File\Uploader->save(), the validateDestination() is called. Inside this function is the use of is_writable() with a relative path.

My solution is to make the destination file be absolute. This seems to fix the problem and should work with any environment.

统计信息

  • 总下载量: 427
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2017-01-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固