mageworx/module-downloads-graph-ql

N/A

安装数: 15,847

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 4

分支: 2

开放问题: 0

类型:magento2-module

1.1.0 2021-03-31 11:07 UTC

This package is not auto-updated.

Last update: 2024-09-26 03:47:27 UTC


README

为Mageworx Magento 2 文件下载 & 产品附件扩展提供的GraphQL API模块。

安装

1) 复制粘贴方法

  • 下载此模块并将其上传到app/code/MageWorx/DownloadsGraphQl目录(如果不存在,请先创建"DownloadsGraphQl"目录)

2) 使用composer(从packagist)进行安装

  • 执行以下命令:composer require mageworx/module-downloads-graph-ql

如何使用

1. ProductInterface描述了此对象可能包含的内容。

由MageWorx扩展,并添加了"mw_attachments"属性。以下表格定义了属性和对象。

icon_type: String. Attachment icon type
icon_type: Int. Attachment ID
name: String. Attachment name
url: String. Attachment URL
size_str: String. Attachment size
downloads_number: Int. Number of downloads
description: String. Attachment description
section_name: String. Section name
section_id: Int. escription: "Section ID

请求

{
  products(filter: { sku: { eq: "24-MB01" } }) {
    items {
      name
      mw_attachments {
        tab_title
        block_title
        items {         
          icon_type
          id
          name
          url
          size_str
          downloads_number
          description
          section_name
          section_id
        }
      }
    }
  }
}

响应

{
  "data": {
    "products": {
      "items": [
        {
          "name": "Joust Duffle Bag",
          "mw_attachments": {
            "tab_title": "File Downloads Tab",
            "block_title": "File Downloads Block",
            "items": [
              {
                "icon_type": "pdf",
                "id": 1,
                "name": "test attachment",
                "url": "",
                "size_str": "2.4 MB",
                "downloads_number": 1,
                "description": "Test description 1",
                "section_name": "Default",
                "section_id": 1
              },
              {
                "icon_type": "",
                "id": 2,
                "name": "URL attach",
                "url": "http://exapmle.com",
                "size_str": null,
                "downloads_number": null,
                "description": "Test description 2",
                "section_name": "Test",
                "section_id": 2
              }
            ]
          }
        }
      ]
    }
  }
}

2. mwFileDownloads查询返回有关下载的信息(CMS页面上的产品附件、小部件等)

查询属性定义如下

attachmentIds: Int. Attachment IDs
sectionIds: Int. Section IDs

默认情况下,您可以使用以下属性

block_title: String @doc(description: "File Downloads Block Title"
is_group_by_section: Boolean. Indicates whether to group attachments by section
how_to_download_message: String. 'How to download' message
items: [MwAttachment] An array of Attachments

请求

{
    mwFileDownloads(attachmentIds:[1]){
        block_title
        is_group_by_section
        how_to_download_message
        items {
          icon_type
          id
          name
          url
          size_str
          downloads_number
          description
          section_name
          section_id
        }
    }
}

响应

{
    "data": {
        "mwFileDownloads": {
            "block_title": "File Downloads Title",
            "is_group_by_section": true,
            "how_to_download_message": "You have to %login% or %register% to download this file",
            "items": [
                {
                    "icon_type": "jpg",
                    "id": 50,
                    "name": "Default Name",
                    "url": "",
                    "size_str": "11.7 KB",
                    "downloads_number": 0,
                    "description": "Default Description",
                    "section_name": "Default",
                    "section_id": 1
                }
            ]
        }
    }
}

通过授权令牌,可以获取客户组的相同信息。