landofcoder/module-seller-productlist-graph-ql

Magento 2 卖家产品列表 GraphQL 扩展

1.0.0 2022-02-24 10:34 UTC

This package is auto-updated.

Last update: 2024-09-09 16:32:47 UTC


README

卖家产品列表 - 产品滑块 GraphQL。通过筛选获取卖家产品列表,包括最新、热销、特色、优惠等...

landofcoder/module-seller-productlist-graph-ql

需求

主要功能

magento 2 产品列表 GraphQL 扩展

安装

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

类型 1:Zip 文件

  • 将 Zip 文件解压到 app/code/Lofmp
  • 运行 php bin/magento module:enable Lofmp_ProductListGraphQl 启用模块
  • 运行 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-productlist-graph-ql 安装模块 composer
  • 运行 php bin/magento module:enable Lofmp_ProductListGraphQl 启用模块
  • 运行 php bin/magento setup:upgrade 应用数据库更新*
  • 运行 php bin/magento cache:flush 清除缓存

TODO

  • 支持全文搜索

查询

获取卖家产品列表

  • 在之前定义片段
fragment ProductPriceFragment on ProductPrice {
  discount {
    amount_off
    percent_off
  }
  final_price {
    currency
    value
  }
  regular_price {
    currency
    value
  }
}

fragment ProductBasicInfo on ProductInterface {
  id
  name
  url_key
  rating_summary
  sku
  image {
    url
    label
  }
  description {
    html
  }
  short_description {
    html
  }
  price_range {
    maximum_price {
      ...ProductPriceFragment
    }
    minimum_price {
      ...ProductPriceFragment
    }
  }
  price {
      regularPrice {
          amount {
              currency
          }
      }
  }
}
  • 使用查询
{
    sellerProductsList(
        sellerUrl: String!
        sourceType: SellerProductSourceType = latest
        search: String
        filter: ProductFilterInput
        pageSize: Int = 20
        currentPage: Int = 1
    ) {
        items {
            ...ProductBasicInfo
        }
        page_info {
          page_size
          current_page
          total_pages
        }
        total_count
    }
}
  • SellerProductSourceType: 枚举类型
enum SellerProductSourceType {
    latest
    newArrival
    special
    mostPopular
    bestseller
    topRated
    random
    featured
    deals
}
  • ProductFilterInput: 已弃用,请使用 @ProductAttributeFilterInput 代替。ProductFilterInput 定义用于搜索的过滤器。一个过滤器至少包含一个属性、一个比较运算符以及要搜索的值。在模块 magento/module-catalog-graph-ql 中查看

示例

查询卖家 URL 键 "seller-a" 的特色产品

{
    sellerProductsList(
        sellerUrl: "seller-a"
        sourceType: featured
        search: ""
        filter: {}
        pageSize: 5
        currentPage: 1
    ) {
        items {
            id
            name
            url_key
            rating_summary
            sku
            image {
              url
              label
            }
            description {
              html
            }
            short_description {
              html
            }
            price {
                regularPrice {
                    amount {
                        currency
                    }
                }
            }
        }
        page_info {
          page_size
          current_page
          total_pages
        }
        total_count
    }
}