landofcoder/module-recent-viewed-products-graph-ql

Magento 2 近期浏览产品 GraphQL

1.0.0 2022-09-27 09:13 UTC

This package is auto-updated.

Last update: 2024-09-27 13:58:55 UTC


README

Magento 2 近期浏览产品 GraphQL 模块。允许提交近期浏览产品 ID,获取近期浏览产品集合

此模块需要管理员在 admin > stores > configuration > General > Report 中启用近期浏览报告

安装

* = 在生产环境中,请使用 --keep-generated 选项

类型 1: 压缩文件

  • 将压缩文件解压到 app/code/Lof
  • 通过运行 php bin/magento module:enable Lof_RecentViewedGraphQl 启用模块
  • 通过运行 php bin/magento setup:upgrade 应用数据库更新 *
  • 通过运行 php bin/magento cache:flush 清除缓存

类型 2: Composer

  • 将模块添加到 composer 存储库中,例如
    • 私有存储库 repo.magento.com
    • 公共存储库 packagist.org
    • 公共 GitHub 存储库作为 vcs
  • 通过运行 composer config repositories.repo.magento.com composer https://repo.magento.com/ 将 composer 存储库添加到配置中
  • 通过运行 composer require landofcoder/module-recent-viewed-products-graph-ql 安装模块 composer
  • 通过运行 php bin/magento module:enable Lof_RecentViewedGraphQl 启用模块
  • 通过运行 php bin/magento setup:upgrade 应用数据库更新 *
  • 通过运行 php bin/magento cache:flush 清除缓存

GraphQL 查询

  1. 查询 - 获取当前登录客户的近期浏览产品

查询

{
  recentViewedProducts(search: "", pageSize: 5, currentPage: 1) {
    total_count
    currentPage
    pageSize
    totalPages
    items {
      id
      sku
      uid
      name
      url_key
      price_range {
        minimum_price {
          regular_price {
            value
            currency
          }
        }
      }
      image {
        url
        label
      }
    }
  }
}

search: 字符串 - 通过关键字搜索

  1. 突变 - 提交当前登录客户的近期浏览产品 ID

查询

mutation {
  recentViewedProducts(product_ids: [Int]!) 
  {
    message
    total_count
  }
}

product_ids: [Int]! - 必须字段,产品 ID 数组