Magento 2.x / Adobe Commerce 2.x Database Optimization To Speed Up Store

The following below steps need to follow.

  • Choose Reliable Hosting
  • Update the Magento Version
  • Upgrade Package & Database
  • Avoid Built-in Cache
  • Keep Indexers Updated
  • Use Varnish Cache
  • Inspect Third-Party Modules
  • Enable Magento Flat Catalogs
  • Optimize Product Images
  • Minify CSS and JavaScript
  • Use Elasticsearch for Instant Results
  • Enable GZIP Compression
  • Integrate Content Delivery Network
  • Clean Database Logs
  • Switch to Production Mode
  • Enable Advance JS Bundling

How To Add Bundle Products in Cart By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

The following below steps need to follow to add Bundle products by using GraphQL in Magento 2.x

Use the updateCartItems mutation to update shopping cart items and removeItemFromCart to remove a product from the shopping cart.

Step [1] – Recommendation to use below Bundle Product syntax

Here Using Postman

Syntax –

mutation {
  addBundleProductsToCart(
    input: AddBundleProductsToCartInput
  ) {
    AddBundleProductsToCartOutput
  }
}

Step [2] – Put below Request

mutation {
  addBundleProductsToCart(
    input: {
      cart_id: "SUAzreA0RsakaL5YcNC2rmgYjfscCZZC"
      cart_items: [
      {
        data: {
          sku: "24-WG080"
          quantity: 1
        }
        bundle_options: [
          {
            id: 1
            quantity: 1
            value: [
              "2"
            ]
          },
          {
            id: 2
            quantity: 2
            value: [
              "4"
            ]
          },
          {
            id: 3
            quantity: 1
            value: [
              "7"
            ]
          },
          {
            id: 4
            quantity: 1
            value: [
              "8"
            ]
          }
        ]
      },
    ]
  }) {
    cart {
      items {
        id
        quantity
        product {
          sku
          name
        }
        ... on BundleCartItem {
          bundle_options {
            id
            label
            type
            values {
              id
              label
              price
              quantity
            }
          }
        }
      }
    }
  }
}

Step [3] – Below output response

{
    "data": {
        "addBundleProductsToCart": {
            "cart": {
                "items": [
                    {
                        "id": "132",
                        "quantity": 14,
                        "product": {
                            "sku": "24-WG080",
                            "name": "Sprite Yoga Companion Kit"
                        },
                        "bundle_options": [
                            {
                                "id": 1,
                                "label": "Sprite Stasis Ball",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 2,
                                        "label": "Sprite Stasis Ball 65 cm",
                                        "price": 27,
                                        "quantity": 1
                                    }
                                ]
                            },
                            {
                                "id": 2,
                                "label": "Sprite Foam Yoga Brick",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 4,
                                        "label": "Sprite Foam Yoga Brick",
                                        "price": 5,
                                        "quantity": 2
                                    }
                                ]
                            },
                            {
                                "id": 3,
                                "label": "Sprite Yoga Strap",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 7,
                                        "label": "Sprite Yoga Strap 10 foot",
                                        "price": 21,
                                        "quantity": 1
                                    }
                                ]
                            },
                            {
                                "id": 4,
                                "label": "Sprite Foam Roller",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 8,
                                        "label": "Sprite Foam Roller",
                                        "price": 19,
                                        "quantity": 1
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "137",
                        "quantity": 6,
                        "product": {
                            "sku": "MH01",
                            "name": "Chaz Kangeroo Hoodie"
                        }
                    }
                ]
            }
        }
    }
}

How To Add Configurable Products By Using GraphQL in Cart in Magento 2.x / Adobe Commerce 2.x

How To Add Configurable Products By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

Use the updateCartItems mutation to update shopping cart items and removeItemFromCart to remove a product from the shopping cart.

The following below steps need to follow to add Configurable products by using GraphQL in Magento 2.x

Step [1] – Recommendation to use below Configurable Product syntax

Here Using Postman

Syntax –

 mutation {
   addConfigurableProductsToCart(
      input: AddConfigurableProductsToCartInput
   ) {
     AddConfigurableProductsToCartOutput
   }
 }

Step [2] – Put below Request

mutation {
  addConfigurableProductsToCart(
    input: {
      cart_id: "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"
      cart_items: [{
        parent_sku: "MH01"
        data: {
          quantity: 2,
          sku: "MH01-XS-Black"
        }
      }]
    }
  ) {
    cart {
      items {
        id
        product {
          name
          sku
          options_container
        }
        quantity
        ... on ConfigurableCartItem{
        	configurable_options{
            id
            option_label
            value_label
            value_id
          }
        }
      }
    }
  }
}

Step [3] – Below output response

{
    "data": {
        "addBundleProductsToCart": {
            "cart": {
                "items": [
                    {
                        "id": "131",
                        "quantity": 2,
                        "product": {
                            "sku": "Gaming-Software",
                            "name": "Gaming-Software"
                        }
                    },
                    {
                        "id": "132",
                        "quantity": 4,
                        "product": {
                            "sku": "24-WG080",
                            "name": "Sprite Yoga Companion Kit"
                        },
                        "bundle_options": [
                            {
                                "id": 1,
                                "label": "Sprite Stasis Ball",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 2,
                                        "label": "Sprite Stasis Ball 65 cm",
                                        "price": 27,
                                        "quantity": 1
                                    }
                                ]
                            },
                            {
                                "id": 2,
                                "label": "Sprite Foam Yoga Brick",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 4,
                                        "label": "Sprite Foam Yoga Brick",
                                        "price": 5,
                                        "quantity": 2
                                    }
                                ]
                            },
                            {
                                "id": 3,
                                "label": "Sprite Yoga Strap",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 7,
                                        "label": "Sprite Yoga Strap 10 foot",
                                        "price": 21,
                                        "quantity": 1
                                    }
                                ]
                            },
                            {
                                "id": 4,
                                "label": "Sprite Foam Roller",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 8,
                                        "label": "Sprite Foam Roller",
                                        "price": 19,
                                        "quantity": 1
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        }
    }
}

How To Add Simple Products By Using GraphQL in Cart in Magento 2.x / Adobe Commerce 2.x

Use the updateCartItems mutation to update shopping cart items and removeItemFromCart to remove a product from the shopping cart.

The following below steps need to follow to add products by using GraphQL in Magento 2.x

Step [1] – Recommendation to use below Simple Product syntax

Here Using Postman

Syntax –

mutation {
  addSimpleProductsToCart(input: AddSimpleProductsToCartInput): {
    AddSimpleProductsToCartOutput
  }
}

Step [2] – Put below Request

mutation {
  addSimpleProductsToCart(
    input: {
      cart_id: "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"
      cart_items: [
        {
          data: {
            quantity: 1
            sku: "24-UB02"
          }
        }
      ]
    }
  ) {
    cart {
      items {
        id
        product {
          sku
          stock_status
        }
        quantity
      }
    }
  }
}

Step [3] – Below output response

{
    "data": {
        "addSimpleProductsToCart": {
            "cart": {
                "items": [
                    {
                        "id": "124",
                        "product": {
                            "sku": "24-UB02",
                            "stock_status": "IN_STOCK"
                        },
                        "quantity": 1
                    }
                ]
            }
        }
    }
}

Product added in quote_item database table with SKU = 24-UB02

How To Create Customer Cart ID For Logged & Guest Customer by GraphQL in Magento 2.x / Adobe Commerce 2.x

The following below steps need to create Customer Cart ID For Logged & Guest Customer By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

We are going to create Customer Cart ID for logged Customer as well as Guest Customer

Before Creating Customer Cart ID, need to specify the customer’s authorization token in the headers. Otherwise, Query Error as “Get customer authorization token”

Step [1] – Customer Cart ID for Logged Customer, use below

customerCart

Step [1.1] – Recommendation to use below Customer Cart ID syntax

Here Using Postman

Syntax –

{
  customerCart{
    id
  }
}

Step [1.2] – Put below Request

{
  customerCart{
    id
  }
}

Step [1.3] – Below output response

{
    "data": {
        "customerCart": {
            "id": "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"
        }
    }
}

Step [2] – Customer Cart ID for Guest Customer, use below

customerEmptyCart

Step [2.1] – Recommendation to use below Customer Cart ID syntax

Here Using Postman

mutation {
  createEmptyCart
}

Step [2.2] – Put below Request

mutation {
  createEmptyCart
}

Step [2.3] – Below Output Response

{

   {
    "data": {
        "createEmptyCart": "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"
    }
}

How To Add Bundle Products in Cart By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

How To Add Bundle Products By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

Use the updateCartItems mutation to update shopping cart items and removeItemFromCart to remove a product from the shopping cart.

The following below steps need to follow to add Configurable products by using GraphQL in Magento 2.x

Here Using Postman

Step [1] – Recommendation to use below Bundle Products syntax

mutation {
addBundleProductsToCart(
input: AddBundleProductsToCartInput
) {
AddBundleProductsToCartOutput
}
}

Step [2] – Put below Request

mutation {
  addBundleProductsToCart(
    input: {
      cart_id: "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"
      cart_items: [
      {
        data: {
          sku: "24-WG080"
          quantity: 1
        }
        bundle_options: [
          {
            id: 1
            quantity: 1
            value: [
              "2"
            ]
          },
          {
            id: 2
            quantity: 2
            value: [
              "4"
            ]
          },
          {
            id: 3
            quantity: 1
            value: [
              "7"
            ]
          },
          {
            id: 4
            quantity: 1
            value: [
              "8"
            ]
          }
        ]
      },
    ]
  }) {
    cart {
      items {
        id
        quantity
        product {
          sku
          name
        }
        ... on BundleCartItem {
          bundle_options {
            id
            label
            type
            values {
              id
              label
              price
              quantity
            }
          }
        }
      }
    }
  }
}

Step [3] – Below output response

{
    "data": {
        "addBundleProductsToCart": {
            "cart": {
                "items": [
                    {
                        "id": "131",
                        "quantity": 2,
                        "product": {
                            "sku": "Gaming-Software",
                            "name": "Gaming-Software"
                        }
                    },
                    {
                        "id": "132",
                        "quantity": 4,
                        "product": {
                            "sku": "24-WG080",
                            "name": "Sprite Yoga Companion Kit"
                        },
                        "bundle_options": [
                            {
                                "id": 1,
                                "label": "Sprite Stasis Ball",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 2,
                                        "label": "Sprite Stasis Ball 65 cm",
                                        "price": 27,
                                        "quantity": 1
                                    }
                                ]
                            },
                            {
                                "id": 2,
                                "label": "Sprite Foam Yoga Brick",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 4,
                                        "label": "Sprite Foam Yoga Brick",
                                        "price": 5,
                                        "quantity": 2
                                    }
                                ]
                            },
                            {
                                "id": 3,
                                "label": "Sprite Yoga Strap",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 7,
                                        "label": "Sprite Yoga Strap 10 foot",
                                        "price": 21,
                                        "quantity": 1
                                    }
                                ]
                            },
                            {
                                "id": 4,
                                "label": "Sprite Foam Roller",
                                "type": "radio",
                                "values": [
                                    {
                                        "id": 8,
                                        "label": "Sprite Foam Roller",
                                        "price": 19,
                                        "quantity": 1
                                    }
                                ]
                            }
                        ]
                    }
                ]
            }
        }
    }
}

How To Add Downloadable Products By Using GraphQL in Cart in Magento 2.x / Adobe Commerce 2.x

How To Add Downloadable Products By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

Use the updateCartItems mutation to update shopping cart items and removeItemFromCart to remove a product from the shopping cart.

The following below steps need to follow to add Downloadable products by using GraphQL in Magento 2.x

Step [1] – Recommendation to use below Downloadable Product syntax

Here Using Postman

Syntax –

mutation {
	 addDownloadableProductsToCart(
	 input: AddDownloadableProductsToCartInput
	 ) {
	 AddDownloadableProductsToCartOutput
	 }
	}

Step [2] – Put below Request

mutation {
  addDownloadableProductsToCart(
    input: {
      cart_id: "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"
      cart_items: {
        data: {
          sku: "Gaming-Software"
          quantity: 1
        }
        downloadable_product_links: [
          {
            link_id: 7                 # Episode 2
          }
          {
            link_id: 8                 # Episode 3
          }
        ]
      }
    }
  ) {
    cart {
      items {
        product {
          id
          sku
          name
        }
        quantity
        ... on DownloadableCartItem {
          links {
            title
            price
          }
          samples {
            title
            sample_url
          }
        }
      }
    }
  }
}

Step [3] – Below output response

{
    "data": {
        "addDownloadableProductsToCart": {
            "cart": {
                "items": [
                    {
                        "product": {
                            "id": 2041,
                            "sku": "Gaming-Software",
                            "name": "Gaming-Software"
                        },
                        "quantity": 1,
                        "links": [
                            {
                                "title": "Gaming Software",
                                "price": 0
                            }
                        ],
                        "samples": []
                    }
                ]
            }
        }
    }
}

How To Create Customer Registration By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

The following below steps need to create Customer Registration Details By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

Step [1] – Recommendation to use below customer customer syntax

Here Using Postman

Syntax –

need to use createCustomer mutation to register the new customer account in the store.

Step [2] – Put below Request

mutation {
  createCustomer(
    input: {
      firstname: "John"
      lastname: "Doe"
      email: "johndusa1021@gmail.com"
      password: "admin123!!"
      is_subscribed: true
    }
  ) {
    customer {
      firstname
      lastname
      email
      is_subscribed
    }
  }
}
Continue reading “How To Create Customer Registration By Using GraphQL in Magento 2.x / Adobe Commerce 2.x”

How To Get Customer’s Wish List Items By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

The following below steps need to follow to get Customer’s Wishlist Items By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

Step [1] – Recommendation to use below Customer’s Wishlist Items syntax

Here Using Postman

Syntax –

wishlist: WishlistOutput

Step [2] – Put below Request

{
  wishlist {
    items_count
    name
    sharing_code
    updated_at
    items {
      id
      qty
      description
      added_at
      product {
        sku
        name
      }
    }
  }
}
Continue reading “How To Get Customer’s Wish List Items By Using GraphQL in Magento 2.x / Adobe Commerce 2.x”