0

I have added mageplaza brands to my magento project and I can get the list of brands that I have with following graphql

query getMpBrands {
  mpbrand(filter: {}, storeId: 1, currentPage: 1, pageSize: 20) {
    total_count
    items {
      attribute_id
      brand_id
      default_value
      description
      image
      is_featured
      meta_description
      meta_keywords
      meta_title
      option_id
      page_title
      short_description
      static_block
      store_id
      url_key
      value
    }
  }
}

Result

{
  "data": {
    "mpbrand": {
      "total_count": 6,
      "items": [
        {
          "attribute_id": 1134,
          "brand_id": 7,
          "default_value": "test 1",
          "description": "test-1",
          "image": "https://uatpwa.nominb2b.mn/media/mageplaza/brand/xiaomi_logo.png",
          "is_featured": 1,
          "meta_description": "test-1",
          "meta_keywords": "test-1",
          "meta_title": "test-1",
          "option_id": 11603,
          "page_title": "test-1",
          "short_description": "test-1",
          "static_block": null,
          "store_id": 1,
          "url_key": "test-1",
          "value": "test 1"
        },
        {
          "attribute_id": 1134,
          "brand_id": 8,
          "default_value": "test 2",
          "description": "test-2",
          "image": "https://uatpwa.nominb2b.mn/media/mageplaza/brand/lg_logo_2.png",
          "is_featured": 1,
          "meta_description": "test-2",
          "meta_keywords": "test-2",
          "meta_title": "test-2",
          "option_id": 11604,
          "page_title": "test-2",
          "short_description": "test-2",
          "static_block": null,
          "store_id": 1,
          "url_key": "test-2",
          "value": "test 2"
        },
        {
          "attribute_id": 1134,
          "brand_id": 9,
          "default_value": "test 3",
          "description": "test-3",
          "image": "https://uatpwa.nominb2b.mn/media/mageplaza/brand/casio_logo_4.png",
          "is_featured": 1,
          "meta_description": "test-3",
          "meta_keywords": "test-3",
          "meta_title": "test-3",
          "option_id": 11605,
          "page_title": "test-3",
          "short_description": "test-3",
          "static_block": null,
          "store_id": 1,
          "url_key": "test-3",
          "value": "test 3"
        },
        {
          "attribute_id": 1134,
          "brand_id": 10,
          "default_value": "test 4",
          "description": "test-4",
          "image": "https://uatpwa.nominb2b.mn/media/mageplaza/brand/the_north_face_2.png",
          "is_featured": 1,
          "meta_description": "test-4",
          "meta_keywords": "test-4",
          "meta_title": "test-4",
          "option_id": 11606,
          "page_title": "test-4",
          "short_description": "test-4",
          "static_block": null,
          "store_id": 1,
          "url_key": "test-4",
          "value": "test 4"
        },
        {
          "attribute_id": 1134,
          "brand_id": 11,
          "default_value": "test 5",
          "description": "test-5",
          "image": "https://uatpwa.nominb2b.mn/media/mageplaza/brand/xiaomi_logo_1.png",
          "is_featured": 1,
          "meta_description": "test-5",
          "meta_keywords": "test-5",
          "meta_title": "test-5",
          "option_id": 11607,
          "page_title": "test-5",
          "short_description": "test-5",
          "static_block": null,
          "store_id": 1,
          "url_key": "test-5",
          "value": "test 5"
        },
        {
          "attribute_id": 1134,
          "brand_id": 12,
          "default_value": "test 6",
          "description": "test-6",
          "image": "https://uatpwa.nominb2b.mn/media/mageplaza/brand/lg_logo_3.png",
          "is_featured": 1,
          "meta_description": "test-6",
          "meta_keywords": "test-6",
          "meta_title": "test-6",
          "option_id": 11608,
          "page_title": "test-6",
          "short_description": "test-6",
          "static_block": null,
          "store_id": 1,
          "url_key": "test-6",
          "value": "test 6"
        }
      ]
    }
  }
}

I need to get the list of products that have the brand_id.Can I get the products by passing the brand_id?What is the graphql I can use.Please help

1 Answer 1

0

I don't know much about GraphQL in Magento, but you should use the products query (https://devdocs.magento.com/guides/v2.4/graphql/queries/products.html) in order to get products and filter them by the brand_id. First of all, check if the result data contain the brand_id attribute, and if so, you can filter the products query using the filter attribute, eg:

{
  products(filter: { brand_id: { eq: "7" } }) {
    items {
      name
      sku
      url_key
      stock_status
      price_range {
        minimum_price {
          regular_price {
            value
            currency
          }
        }
      }
    }
    total_count
    page_info {
      page_size
    }
  }
}    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.