custom/plugins/CeCustomerSubaccounts/src/Storefront/Controller/SubaccountController.php line 20

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Ce\CustomerSubaccounts\Storefront\Controller;
  3. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  4. use Shopware\Storefront\Controller\StorefrontController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use GuzzleHttp;
  9. /**
  10.  * @Route(defaults={"_routeScope"={"storefront"}})
  11.  */
  12. class SubaccountController extends StorefrontController
  13. {
  14.     /**
  15.      * @Route("/subaccount", name="frontend.subaccount.example", defaults={"csrf_protected"=false}, methods={"GET"})
  16.      */
  17.     public function showExample(Request $requestSalesChannelContext $context): Response
  18.     {
  19. //      $clientId = 'SWIAMML6Z3BBEFBXEG5TV3VSTW';
  20. //      $clientSecret = 'OFM3SER4OVNCSWhkcDZFQ3V3cWFQa2RiNmZtRGNIeFdaNlplUFQ';
  21.         $clientId 'SWIACTDKBLD2CULHU3BBQM5NEA';
  22.         $clientSecret 'aDdzNEpwQUk5Vm9GdjFZaUxHalY1c0dNa0lTRFFJcEJGeG9NY2s';
  23. //      SWSCPSHKQ-Y-FZL1LFS-RM20AW
  24. //        $curl = curl_init();
  25. //        curl_setopt($curl, CURLOPT_POST, 1);
  26. //        $curlopt[CURLOPT_POSTFIELDS] = $parameters_string;
  27. //        curl_setopt_array($curl, [
  28. //            CURLOPT_URL => "http://localhost/store-api/account/register",
  29. //            CURLOPT_RETURNTRANSFER => true,
  30. //            CURLOPT_ENCODING => "",
  31. //            CURLOPT_MAXREDIRS => 10,
  32. //            CURLOPT_TIMEOUT => 30,
  33. //            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  34. //            CURLOPT_CUSTOMREQUEST => "POST",
  35. //            CURLOPT_POSTFIELDS => "{\n
  36. //            \"firstName\": \"Alice\",\n
  37. //            \"lastName\": \"Apple\",\n
  38. //            \"email\": \"alice.apple@example.com\",\n
  39. //            \"password\": \"ilovefruits\",\n
  40. //            \"storefrontUrl\": \"http://localhost\",\n
  41. //            \"billingAddress\": {\n
  42. //            \"street\": \"Apple Alley 42\",\n
  43. //            \"zipcode\": \"1234-5\",\n
  44. //            \"city\": \"Appleton\",\n
  45. //            \"countryId\": \"0x88d0dabde41146199a6edbe18eb57fea\"\n  }\n}",
  46. //            CURLOPT_HTTPHEADER => [
  47. //                "Accept: application/json",
  48. //                "Content-Type: application/json",
  49. //                "sw-access-key: SWSCPSHKQ-Y-FZL1LFS-RM20AW",
  50. //                "sw-context-token: ".$context->getToken()
  51. //            ],
  52. //        ]);
  53. //
  54. //        $response = curl_exec($curl);
  55. //        $err = curl_error($curl);
  56. //
  57. //        curl_close($curl);
  58. //
  59. //        if ($err) {
  60. //            echo "cURL Error #:" . $err;
  61. //        } else {
  62. //            echo $response;
  63. //        }
  64.         $curl curl_init();
  65.         curl_setopt_array($curl, [
  66.             CURLOPT_URL => "http://sw6afg.ce1.eu/store-api/context",
  67.             CURLOPT_RETURNTRANSFER => true,
  68.             CURLOPT_ENCODING => "",
  69.             CURLOPT_MAXREDIRS => 10,
  70.             CURLOPT_TIMEOUT => 30,
  71.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  72.             CURLOPT_CUSTOMREQUEST => "GET",
  73.             CURLOPT_HTTPHEADER => [
  74.                 "Accept: application/json",
  75.                 "Content-Type: application/json",
  76.                 "sw-access-key: SWSCPSHKQ-Y-FZL1LFS-RM20AW"
  77.             ],
  78.         ]);
  79.         $response curl_exec($curl);
  80.         $err curl_error($curl);
  81.         curl_close($curl);
  82.         if ($err) {
  83. //            echo "cURL Error #:" . $err;
  84.         } else {
  85. //            echo $response;
  86.         }
  87. //        var_dump($response);
  88. //        die();
  89.         return $this->renderStorefront('@CeCustomerSubaccounts/storefront/page/subaccount.html.twig', [
  90.             'example' => 'Subaccounts'
  91.         ]);
  92.     }
  93. }