I need to show Product Data (Name SKU)in front end using graphQL is this possible to show Product Data custom page in Magento 2 ?

1 Answer 1


Yes It's possible... Create new template file and link in xml file where you want... And Paste this codes in template file...

$query = '
    query {
    products(filter: {category_id: {eq: "2"}}) {
    items {

$json = json_encode(['query' => $query]);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '[YOUR END POINT]');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);    
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_HTTPHEADER,
            'User-Agent: PHP Script',
            'Content-Type: application/json;charset=utf-8',
            'Authorization: bearer [YOUR TOKEN]' 

$response = curl_exec($curl);
echo "<pre>",var_dump($response),"</pre>";


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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