承接 magento/module-upward-connector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

magento/module-upward-connector

Composer 安装命令:

composer require magento/module-upward-connector

包简介

Magento module used for routing all frontend requests through UPWARD-PHP.

README 文档

README

The Magento 2 UPWARD connector is a module for routing requests to UPWARD-PHP. This module replaces the default Magento frontend theme with a PWA Studio storefront application.

PWA Studio storefront deployments in the Magento Commerce Cloud use this module to keep Magento and storefront code on the same server.

Installation

The Magento 2 UPWARD connector module is part of the Magento Cloud deployment steps in the official PWA Studio docs.

Configuration

The Magento 2 UPWARD connector has additional settings that can be configured in the admin area under:

Stores > Configuration > General > Web > UPWARD PWA Configuration.

General configuration

These are the configurations for the UPWARD process itself.

UPWARD Config File

This configuration is the location of the UPWARD configuration file for the UPWARD-PHP server.

This module adds a new directive to the env.php to securely set the path to the upward.yaml file.

    // ...
    'downloadable_domains' => [
        // ...
    ],
    # New configuration point
    'pwa_path' => [
        'default' => [
            'default' => '/var/www/html/pwa/dist/upward.yml'
        ],
        'website' => [
            '<website_code>' => '/var/www/html/anotherpwa/dist/upward.yml' # Can point a website to a different installation
        ],
        'store' => [
            '<store_code>' => '' # Blank string (or false) to serve default Magento storefront
        ]
    ]

For ease of use, this module provides a new command for setting the path

# Set the default scope to an empty string (will serve base Magento store front)
bin/magento pwa:upward:set

# Set the website with code <website_code> to /var/www/html/pwa/dist/upward.yml
bin/magento pwa:upward:set --path /var/www/html/pwa/dist/upward.yml --scopeType website --scopeCode <website_code>

# Set the website with code <website_code> to an empty string (will serve base Magento store front)
bin/magento pwa:upward:set --scopeType website --scopeCode <website_code>

# Set the website with code <store_code> to /var/www/html/pwa/dist/upward.yml
bin/magento pwa:upward:set --path /var/www/html/pwa/dist/upward.yml --scopeType store --scopeCode <store_code>

You can use bin/magento store:list or bin/magento store:website:list to easily get the store/website code for configuration.

You may use a path relative to your web root or an absolute path for the value of this configuration.

  • Relative: pwa/dist/upward.yml
  • Absolute: /var/www/html/pwa/dist/upward.yml

If you have previously configured the UPWARD yaml path using the config:set command or environment variables, it will continue to work as a fallback, so long as no default has been set as per the example above.

The configuration works the same way normal store configurations work. It falls back from store view > website > global (default), trying to serve the more specific available scope first.

Front Name Allowlist

This configuration allows you to specify a line-separated list of routes to forward to the default Magento theme.

Example:

contact
privacy-policy-cookie-restriction-mode

With this example, when a visitor navigates to either <Magento store URL>/contact or <Magento store URL>/privacy-policy-cookie-restriction-mode, they will land on a page rendered by Magento instead of the storefront application.

Prerender.io Configuration

Prerender.io support in the upward-connector module allows your site to send prerendered static html to search bots.

A middleware layer checks each request to see if it comes from a crawler and if allowed, sends it to the prerender service. These configuration entries let you configure which pages to send to Prerender.io to serve the static HTML versions of that page. If a page is not configured for prerendering, the request continues using the normal server routes.

Configuration Description Example
Enable Prerender For Search Bots This enables prerender functionality for this store view.
Prerender URL Url of the prerender service. https://service.prerender.io/
Prerender.io Token Token to use for the prenderer.io hosted service
Crawler User Agents Line break separated list of keywords to detect the crawler in the user-agent request header
Blocked List Resources that will not be sent for prerendering. Use * as a wildcard character. .js */cart
Allowed List Explicitly allowed resources to be sent for prerendering. If empty, all resources are allowed.

Testing prerendered pages

To see how a crawler sees a prerendered page, set your browser's User Agent to Googlebot and visit your URL. You can also run this on the command line and change the sample URL to your storefront's URL:

curl -A Googlebot https://www.example.com/ > page.html

To configure prerender locally for testing purposes, see https://docs.prerender.io/test-it/.

Troubleshooting partial rendered pages

There is no way to tell when a PWA page fully loads. For prerendering it is possible to force prerender to wait for a predefined timeout before setting the window.prerenderReady flag.

Add the following to the runtime script:

window.prerenderReady = false;
setTimeout(function () {
  window.prerenderReady = true;
}, 1000 * 15);

For more information, see https://docs.prerender.io/test-it/.

Service Worker Note

Avoid sharing the same hostname between your PWA Studio storefront and the Magento 2 admin backend. This causes the storefront Service Worker to intercept backend requests when you have both the storefront and admin tabs open at the same time on your browser. If you cannot avoid sharing the hostname, access one service at a time or use a private browsing session per service.

magento/module-upward-connector 适用场景与选型建议

magento/module-upward-connector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 430.43k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2019 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 magento/module-upward-connector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 magento/module-upward-connector 我们能提供哪些服务?
定制开发 / 二次开发

基于 magento/module-upward-connector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 430.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 14
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 24
  • Watchers: 12
  • Forks: 24
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2019-03-27