src/project/OfficeBrain/CustomBundle/ProductBundle/Controller/ProductController.php line 963

Open in your IDE?
  1. <?php
  2. namespace App\project\OfficeBrain\CustomBundle\ProductBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  6. use App\OfficeBrain\Bundle\ProductBundle\Controller\ProductController as BaseProductController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use DateTime;
  9. use App\OfficeBrain\Bundle\CoreBundle\Cache\RedisCacheService;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Aws\S3\S3Client;
  12. use Aws\Credentials\Credentials as Credentials;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\DependencyInjection\ContainerInterface as Container;
  15. use App\OfficeBrain\Bundle\ProductBundle\Manager\Service\ProductAdminManager;
  16. use App\OfficeBrain\Bundle\EmailBundle\Manager\Service\EmailService;
  17. use App\OfficeBrain\Bundle\ProductTagBundle\Manager\Service\ProductTagManager;
  18. use App\project\OfficeBrain\CustomBundle\ProductBundle\Manager\Service\ProductDetailService as CustomProductDetailService;
  19. use App\OfficeBrain\Bundle\ProductBundle\Manager\Service\ProductDetailService;
  20. use App\OfficeBrain\Bundle\SearchBundle\Manager\Service\SearchManager;
  21. use App\OfficeBrain\Bundle\SolrBundle\Manager\Service\SolrService;
  22. use Symfony\Component\Routing\RouterInterface;
  23. use Symfony\Component\HttpFoundation\RequestStack;
  24. use Symfony\Component\Validator\Validator\ValidatorInterface;
  25. /**
  26.  *
  27.  * @author Employee Id: 4464
  28.  *        
  29.  *         To create custom code
  30.  *        
  31.  * @return NULL
  32.  *
  33.  * @Route("/{_locale}")
  34.  */
  35. class ProductController extends BaseProductController
  36. {
  37.     /**
  38.      *
  39.      * @author Employee Id: 4464
  40.      *        
  41.      *         To set member variables default value
  42.      *        
  43.      * @return NULL
  44.      *
  45.      */
  46.     public function __construct(Container $serviceContainerSearchManager $searchManagerCustomProductDetailService $customProductDetailServiceEmailService $emailServiceProductAdminManager $productAdminManagerSolrService $solrServiceRouterInterface $routerValidatorInterface $validatorRequestStack $requestStackProductTagManager $productTagManagerProductDetailService $productDetailService)
  47.     {
  48.         parent::__construct($serviceContainer$searchManager$productDetailService$emailService$productAdminManager$solrService$router$validator$requestStack);
  49.         $this->statsh_cache_wrapper RedisCacheService::create();
  50.         $this->moduleCachePrefix '__RelatedProducts__';
  51.         $this->wasabiCredentials = new Credentials('RXKLAMY4M3FSY3XXR2AW''Xh9z0rX7EFPLrBlcpM5ec5DpJ3rRndwGz93K8w4O');
  52.         
  53.         $this->s3Client = new S3Client([
  54.             'endpoint' => 'http://s3.us-west-1.wasabisys.com',
  55.             'region' => 'us-west-1',
  56.             'version' => 'latest',
  57.             'credentials' => $this->wasabiCredentials
  58.         ]);
  59.         
  60.         $this->productApiManager $productAdminManager;
  61.         $this->productDetailManager $customProductDetailService->getProductApiExtended(); // 
  62.         $this->productTagManager $productTagManager->getProductTagManagerExtended(); // symfony 4
  63.         $this->emailService $emailService->getEmailExtended();
  64.         $this->wasabiBucket 'ob-aakronftp';
  65.         
  66.         
  67.         
  68.     }
  69.     /**
  70.      *
  71.      * @author Employee Id: 4464
  72.      *        
  73.      *         To unseset member variables
  74.      *        
  75.      * @return NULL
  76.      */
  77.     public function __destruct()
  78.     {
  79.         parent::__destruct();
  80.     }
  81.     /**
  82.      *
  83.      * @author Employee Id: 4464
  84.      *        
  85.      *         To Initialize the member variables
  86.      *        
  87.      * @return NULL
  88.      */
  89.     public function initAction(Request $request)
  90.     {
  91.         parent::initAction($request);
  92.         // $this->productDetailManager = $this->serviceContainer->get('office_brain_product_detail_manager_custom'); // project\OfficeBrain\CustomBundle\ProductBundle\Manager\Extended\ProductApiExtended
  93.         $this->productDetailManager $this->productDetailManager// project\OfficeBrain\CustomBundle\ProductBundle\Manager\Extended\ProductApiExtended
  94.         // $this->productApiManager = $this->serviceContainer->get("office_brain_product_admin_manager");
  95.         $this->productApiManager $this->productApiManager;
  96.         // $this->productTagManager = $this->serviceContainer->get('office_brain_product_tag_manager'); // symfony 4
  97.         $this->productTagManager $this->productTagManager// symfony 4
  98.         // $this->productTagManager = $this->get('office_brain_private_tag_extended');
  99.         $this->categoryApi $this->serviceContainer->get("officebrain_category_api");
  100.         $this->userId $this->projectSetting['user_id'];
  101.         // $this->emailService = $this->serviceContainer->get('office_brain_email_service');
  102.         $this->emailService $this->emailService;
  103.         $this->languageId $this->projectSetting['culture_id'];
  104.     }
  105.     /**
  106.      *
  107.      * @author Employee Id: 4464
  108.      *        
  109.      *         Product Detail data.
  110.      *        
  111.      * @param
  112.      *            string product slug
  113.      *            
  114.      * @return product detail information
  115.      *        
  116.      * @Route("/similar-sku/{productSku}",name="officebrain_product_bundle_similarproductsku", methods={"GET"})
  117.      *
  118.      * @Template()
  119.      *
  120.      */
  121.     public function similarProductSkuAction(Request $request)
  122.     {
  123.         $this->initAction($request);
  124.         $this->responseArray['similarSkuProducts'] = null;
  125.         $productSku $orgProductSKU $this->request->get('productSku'null);
  126.         $productSku explode('-'$productSku);
  127.         if (is_array($productSku)) {
  128.             if (count($productSku) > 1) {
  129.                 // PATCH: For SKUs with closeout. Eg. 1234-Closeout
  130.                 if (strtolower($productSku[1]) == 'closeout') {
  131.                     unset($productSku[1]);
  132.                 } else {
  133.                     // unset($productSku[0]);
  134.                     $productSku = (array) $productSku[count($productSku) - 1];
  135.                 }
  136.             }
  137.             $productSku implode('-'$productSku);
  138.             $similarSkuProducts $this->productDetailManager->getSimilarSku($productSku);
  139.             $this->responseArray['productSku'] = $orgProductSKU;
  140.             $this->responseArray['similarSkuProducts'] = $similarSkuProducts['search_result_array']['data'];
  141.         }
  142.         return $this->responseArray;
  143.     }
  144.     /**
  145.      *
  146.      * @author Employee Id: 5460
  147.      *        
  148.      * @param
  149.      *            product_id.
  150.      *            
  151.      * @return Response
  152.      *
  153.      * @Route("/general-conformity-certificate/{product_sku}",
  154.      *     name="officebrain_custombundle_productbundle_productdetail_gcc", options={"expose"=true}
  155.      * )
  156.      *
  157.      * @Template("project/OfficeBrain/CustomBundle/ProductBundle/Product/generalConformityCertificate.html.twig")
  158.      */
  159.     public function generalConformityCertificateAction(Request $request$product_sku)
  160.     {
  161.            /*$resp = $this->s3Client->listObjects([
  162.                  'Bucket' => $this->wasabiBucket,
  163.                  'Range' => 'bytes=0-9',
  164.                  
  165.              ]);
  166.              echo "Succeed in retrieving bucket ACL as follows: \n";
  167.              echo "<pre>";print_r($resp->get('Contents')); 
  168.              //$search = 'Chem_Tests/'.$product_sku.'*'
  169.              //print_r( array_key_exists_wildcard( $array, $search ) );
  170.              
  171.              die;  
  172.              */
  173.          
  174.         $this->initAction($request);
  175.         $this->responseArray['gccData'] = $this->productDetailManager->getProductgeneralConformityCertificate($product_sku);
  176.         $this->responseArray['gccData'] = $this->productDetailManager->updateColorTestResultURLs($this->responseArray['gccData'],$this->s3Client);
  177.         // print_r($this->responseArray['gccData']);die;
  178.         $this->responseArray['productSku'] = $product_sku;
  179.         return $this->responseArray;
  180.     }
  181.     /**
  182.      *
  183.      * @author Employee Id: 5460
  184.      *        
  185.      *         Desciption: print detail of general conformity certificate
  186.      *        
  187.      * @param
  188.      *            product_id.
  189.      *            
  190.      * @return Response
  191.      *
  192.      * @Route("/general-conformity-certificate-print/{product_sku}",
  193.      *     name="officebrain_custombundle_productbundle_productdetail_gcc_print"
  194.      * )
  195.      *
  196.      * @Template("project/OfficeBrain/CustomBundle/ProductBundle/Product/generalConformityCertificatePrint.html.twig")
  197.      */
  198.     public function generalConformityCertificatePrintAction(Request $request$product_sku)
  199.     {
  200.         
  201.         $this->initAction($request);
  202.         $this->responseArray['gccData'] = $this->productDetailManager->getProductGeneralConformityCertificate($product_sku);
  203.         $this->responseArray['productSku'] = $product_sku;
  204.         return $this->responseArray;
  205.     }
  206.     /**
  207.      *
  208.      * @author Employee Id: 5460
  209.      *        
  210.      * Desciption: download pdf of general conformity certificate
  211.      *        
  212.      * @param
  213.      * product_id.
  214.      *            
  215.      * @return Response
  216.      *
  217.      * @Route("/general-conformity-certificate-pdf/{product_sku}",
  218.      *     name="officebrain_custombundle_productbundle_productdetail_gcc_pdf"
  219.      * )
  220.      */
  221.     public function generalConformityCertificatePdfAction(Request $request$product_sku)
  222.     {
  223.         $response_array $this->generalConformityCertificatePrintAction($product_sku);
  224.         $response $this->render('OfficeBrainCustomBundleProductBundle:Product:generalConformityCertificatePrint.html.twig'$response_array);
  225.         return new Response($this->get('knp_snappy.pdf')->getOutputFromHtml($response->getContent()), 200, array(
  226.             'Content-Type' => 'application/pdf',
  227.             'Content-Disposition' => 'attachment; filename="' $product_sku '-gcc.pdf"'
  228.         ));
  229.     }
  230.     /**
  231.      *
  232.      * @author Employee Id: 5460
  233.      *        
  234.      *         Desciption: download pdf of general conformity certificate test result
  235.      *        
  236.      * @param
  237.      *            product_id.
  238.      *            
  239.      * @return Response
  240.      *
  241.      * @Route("/general-conformity-certificate-test-result-pdf/{test_report_file_name}",
  242.      *     name="officebrain_custombundle_productbundle_productdetail_gcc_test_result_pdf"
  243.      * )
  244.      */
  245.     public function downloadTestResultPdfAction(Request $request$test_report_file_name)
  246.     {
  247.         
  248.         try {
  249.             
  250. //             $resp = $this->s3Client->listObjects([
  251. //                 'Bucket' => $this->wasabiBucket,
  252. //                 'key' => "Chem_Tests/01300-30619 Blue PO#47740.pdf",
  253. //                 'Range' => 'bytes=0-9',
  254. //             ]);
  255.             $resp $this->s3Client->getObject([
  256.                  'Bucket' => $this->wasabiBucket,
  257.                 'Key' => 'Chem_Tests/'.$test_report_file_name,
  258.              ]);
  259. //             echo "Succeed in retrieving bucket ACL as follows: \n";exit;
  260. //             echo "<pre>";print_r($resp['Body']);exit;
  261.             return new Response($resp['Body'], 200, array(
  262.                 'Content-Type' => 'application/pdf',
  263.                 'Content-Disposition' => 'attachment;'
  264.             ));
  265.             //    header("Content-Type: {$result['ContentType']}");
  266.             //    echo $result['Body'];
  267.         } catch (\Exception $e) {
  268. //             die('error');
  269.             // output error message if fails
  270.             return new JsonResponse($e->getMessage());
  271.         }
  272. //         $downloadTestResultBaseUrl = $this->container->getParameter('download_test_result.base_url');
  273. //         $downloadTestResultPDFUrl = $downloadTestResultBaseUrl . "/" . $test_report_file_name;
  274. //         return new Response(file_get_contents($downloadTestResultPDFUrl), 200, array(
  275. //             'Content-Type' => 'application/pdf',
  276. //             'Content-Disposition' => 'attachment;'
  277. //         ));
  278.     }
  279.     
  280.     
  281.      /**
  282.      * @Route("/product/estimator",
  283.      *     name="officebrain_product_bundle_product_detail_estimator", methods={"GET"}
  284.      * )
  285.      *
  286.      * @Template("OfficeBrain/Bundle/ProductBundle/Product/productDetailEstimator.html.twig")
  287.      *
  288.      */
  289.     public function productDetailEstimatorAction(Request $request)
  290.     {
  291.         $this->initAction($request);
  292.         $sku $this->request->get('sku_number'null);
  293.         return array('sku_number' => $sku);
  294.     }
  295.     
  296.     /**
  297.      *
  298.      * @author Employee Id: 4532
  299.      *        
  300.      *         Product Detail data.
  301.      *        
  302.      * @param
  303.      *            string product slug
  304.      *            
  305.      * @return product detail information
  306.      *        
  307.      * @Route("/product/{productSlug}",
  308.      *     name="officebrain_product_bundle_product_detail",
  309.      *  defaults={"main_image_url"=null}, methods={"GET"}
  310.      * )
  311.      *
  312.      * @Template("OfficeBrain/Bundle/ProductBundle/Product/productDetail.html.twig")
  313.      *
  314.      */
  315.     public function productDetailAction(Request $request$productSlug)
  316.     {   
  317. //         $credentials = new Aws\Credentials\Credentials('RXKLAMY4M3FSY3XXR2AW', 'Xh9z0rX7EFPLrBlcpM5ec5DpJ3rRndwGz93K8w4O');
  318.         
  319. //         $s3Client = new S3Client([
  320. //             'endpoint' => 'http://s3.us-west-1.wasabisys.com',
  321. //             'region' => 'us-west-1',
  322. //             'version' => 'latest',
  323. //             'credentials' => $credentials
  324. //         ]);
  325.         
  326. //         $bucket = 'ob-aakronftp';
  327.         
  328. //         try {
  329.             
  330. //             $resp = $s3Client->listObjects([
  331. //                 'Bucket' => $bucket,
  332. //                 'Range' => 'bytes=0-9',
  333. //             ]);
  334. //             /* $resp = $s3Client->getObject([
  335. //              'Bucket' => $bucket,
  336. //              'Key' => 'Chem_Tests/# 47910 Halycon Bottle FDA.pdf'
  337. //              ]);*/
  338. //             echo "Succeed in retrieving bucket ACL as follows: \n";
  339. //             echo "<pre>";print_r($resp);
  340. //             //    header("Content-Type: {$result['ContentType']}");
  341. //             //    echo $result['Body'];
  342. //         } catch (AwsException $e) {
  343. //             // output error message if fails
  344.             
  345. //             echo $e->getMessage();
  346. //             echo "\n";
  347.         // At start of script
  348.         //$time_start = microtime(true);
  349.        // echo 'Total execution time in seconds: ' . (microtime(true) - $time_start);
  350.         // Anywhere else in the script
  351.         
  352. //         }
  353.             
  354.         $this->initAction($request);
  355.         
  356.         if (is_numeric($productSlug)) {
  357.             $productDetailArrayId $this->productDetailManager->getProductDetailById($productSlug$this->cultureCode);
  358.             $this->responseArray $productDetailArrayId[$productSlug];
  359.         } else {
  360.             $this->responseArray $this->productDetailManager->getProductDetailBySlug($productSlug$this->cultureCode);
  361.         }
  362.         if ($this->responseArray == null) {
  363.             /* if no product found Through exception */
  364.             throw $this->createNotFoundException($this->translator->trans('transaction.page_not_found.detail'));
  365.         } // elseif(($this->responseArray['basic_information']['active'] != 1 && $this->responseArray['basic_information']['active'] != true) || ($this->responseArray['is_deleted'] != 1 && $this->responseArray['is_deleted'] != false) ){
  366.         elseif (($this->responseArray['basic_information']['active'] != && $this->responseArray['basic_information']['active'] != true) || ($this->responseArray['is_deleted'] != false)) {
  367.             throw $this->createNotFoundException($this->translator->trans('transaction.page_not_found.detail'));
  368.         }
  369.         /* ------------ Cache Code For Product Details Page -------------- */
  370.         $productId $this->responseArray['product_id'];
  371.         $isUserLoggedIn $this->userId>0?"_not_login":"_loggedin_";
  372.         $this->moduleCachePrefix '__ProductDetailsPageOtherProducts__';
  373.         $locale $this->request->getLocale();
  374.         $cacheSiteKey = array(
  375.             $this->moduleCachePrefix,
  376.             "product_id#" $productId,
  377.             $locale,
  378.             $isUserLoggedIn,
  379.             $this->projectSetting['instance_id'],
  380.             // $this->container->getParameter('kernel.environment') // symfony 4
  381.             $this->projectSetting['kernelEnvironment']
  382.         );
  383.         $cacheKey RedisCacheService::generateKey($this->statsh_cache_wrapper$cacheSiteKey);
  384.         $cacheData RedisCacheService::getCacheData($this->statsh_cache_wrapper$cacheKey);
  385.         if ($cacheData) {
  386.             /** Update Cache data for Flyer and Image */
  387.             $productSKU $cacheData['basic_information']['sku_number'];
  388.             $supplierId $cacheData['supplier']['supplier_id'];
  389.             $downloadImageRelativePath $this->serviceContainer->getParameter('product_image.zip_path');
  390.             $blankFileFullPath $downloadImageRelativePath.$supplierId.'/blank-images/'.$productSKU.'.zip';
  391.             $cacheData['download_blank_image_status'] = file_exists($blankFileFullPath)?1:0;
  392.             $downloadPdfRelativePath $this->serviceContainer->getParameter('product_pdf.flyer_path');
  393.             $pdfFileFullPath $downloadPdfRelativePath.$supplierId.'/flyers/'.$productSKU.'.pdf';
  394.             $cacheData['download_flyer_status'] = file_exists($pdfFileFullPath)?1:0;
  395.             //    return $cacheData;
  396.         }
  397.         /* ------------ EO: Cache Code For Product Details Page -------------- */
  398.         // feature details - made array for simply access
  399.         $featuresDetail = [];
  400.         $this->responseArray['isPackagingOpt'] = false;
  401.         $this->responseArray['isUsaConnect'] = 0;
  402.         foreach ($this->responseArray['feature_details'] as $feature) {
  403.             if($feature['label']=='Packaging Options'){
  404.                 $this->responseArray['isPackagingOpt'] = true;
  405.             }
  406.             if($feature['label']=='is_usa_connect' && !empty($feature['value'])){
  407.                 $this->responseArray['isUsaConnect'] = 1;
  408.             }
  409.             $featuresDetail[$feature['label']] = $feature['value'];
  410.         }
  411.         $categoryArr = array();
  412.         $categoryId '';
  413.         if (is_array($this->responseArray['category']) && count($this->responseArray['category'])) {
  414.             foreach ($this->responseArray['category'] as $key => $value) {
  415.                 if (isset($featuresDetail['Main_Category'])) {
  416.                     if ($featuresDetail['Main_Category'] == $value) {
  417.                         $categoryId $key;
  418.                     }
  419.                 }
  420.                 else {
  421.                     $categoryId $key;
  422.                 }
  423.                 array_push($categoryArr$key);
  424.             }
  425.          $this->responseArray['breadcrumbs'] = $this->productDetailManager->productDetailBreadcrumbs($categoryId$featuresDetail$categoryArr);
  426.         }
  427.         /* Product Tag section Starts */
  428.         if ($this->productConfigurationRules['show_product_tags']['status'] == 1) {
  429.             $main_sku explode('-'$this->responseArray['basic_information']['sku_number']);
  430.             $main_sku $main_sku[count($main_sku) - 1];
  431.             $this->responseArray['product_tags_array'] = $this->productDetailManager->getAllTagsByProductSku($main_sku);
  432.             $tagData $this->productTagManager->getAllTagsByProductId($this->responseArray['product_id'], $this->cultureCode);
  433.             $this->responseArray['product_tags_array'] = $tagData['private_tag'];
  434.         }
  435.         
  436.         /* Product Tag section Ends */
  437.         $this->productDetailManager->recentViewProductByCookies('recent_product_cookie'$this->responseArray['product_id'], $this->cultureCode);
  438.         unset($productDetailArrayId);
  439.         /*
  440.          * Check Ob_customer id - for flyer which is visible or not
  441.          */
  442.         /* check for Availability */
  443.         $date1 date('Y-m-d');
  444.         if ($this->responseArray['basic_information']['valid_up_to'] != '') {
  445.             $dte DateTime::createFromFormat('m-d-Y'$this->responseArray['basic_information']['valid_up_to']);
  446.             $date2 $dte->format('Y-m-d');
  447.             if (strtotime($date1) > strtotime($date2)) {
  448.                 // $st = 'Expired';
  449.                 $st '';
  450.             } else {
  451.                 // $st = 'In-Stock';
  452.                 $st $this->responseArray['basic_information']['valid_up_to'];
  453.             }
  454.         } else {
  455.             $st '';
  456.         }
  457.         $this->responseArray['basic_information']['valid_status'] = $st;
  458.         /* Releted Product section Starts */
  459.         $productId $this->responseArray['product_id'];
  460.         $comproductreletedid $this->productApiManager->productreletedid($productId);
  461.         $this->responseArray['related_product'] = count($comproductreletedid);
  462.         // if($this->userId > 0)
  463.         // {
  464.         $this->responseArray['psa_special'] = $this->productDetailManager->psaSpecialView($productId);
  465.         $this->responseArray['selling_ideas'] = $this->productDetailManager->sellingIdeasView($productId);
  466.         // }
  467.         $this->responseArray['disable_overseas_pricing'] = 0;
  468.         if (isset($this->responseArray['basic_information']['sku_number']) && ! empty($this->responseArray['basic_information']['sku_number'])) {
  469.             $disableOverseasPricingArray $this->serviceContainer->getParameter('disable_overseas_pricing');
  470.             if (in_array($this->responseArray['basic_information']['sku_number'], $disableOverseasPricingArray)) {
  471.                 $this->responseArray['disable_overseas_pricing'] = 1;
  472.             }
  473.         }
  474.         $this->responseArray['tariff_impacted_item'] = 0;
  475.         if (isset($this->responseArray['basic_information']['sku_number']) && ! empty($this->responseArray['basic_information']['sku_number'])) {
  476.             $tariffImpactesItemPricingArray $this->serviceContainer->getParameter('tariff_impacted_item');
  477.             if (in_array($this->responseArray['basic_information']['sku_number'], $tariffImpactesItemPricingArray)) {
  478.                 $this->responseArray['tariff_impacted_item'] = 1;
  479.             }
  480.         }
  481.         $this->responseArray['imprint_color_msg'] = 0;
  482.         if (isset($this->responseArray['basic_information']['sku_number']) && ! empty($this->responseArray['basic_information']['sku_number'])) {
  483.             $impintMsgArray $this->serviceContainer->getParameter('imprint_color_msg');
  484.             if (in_array($this->responseArray['basic_information']['sku_number'], $impintMsgArray)) {
  485.                 $this->responseArray['imprint_color_msg'] = 1;
  486.             }
  487.         }
  488.         $this->responseArray['virtual_hide_button_item'] = 0;
  489.         if (isset($this->responseArray['basic_information']['sku_number']) && ! empty($this->responseArray['basic_information']['sku_number'])) {
  490.             $virtualHideButtonItemArray $this->serviceContainer->getParameter('virtual_hide_button_item');
  491.             if (in_array($this->responseArray['basic_information']['sku_number'], $virtualHideButtonItemArray)) {
  492.                 $this->responseArray['virtual_hide_button_item'] = 1;
  493.             }
  494.         }
  495.         $productSKU $this->responseArray['basic_information']['sku_number'];
  496.         $supplierId $this->responseArray['supplier']['supplier_id'];
  497.         $downloadImageRelativePath $this->serviceContainer->getParameter('product_image.zip_path');
  498.         $blankFileFullPath $downloadImageRelativePath.$supplierId.'/blank-images/'.$productSKU.'.zip';
  499.         $this->responseArray['download_blank_image_status'] = file_exists($blankFileFullPath)?1:0;
  500.         $downloadPdfRelativePath $this->serviceContainer->getParameter('product_pdf.flyer_path');
  501.         $pdfFileFullPath $downloadPdfRelativePath.$supplierId.'/flyers/'.$productSKU.'.pdf';
  502.         $this->responseArray['download_flyer_status'] = file_exists($pdfFileFullPath)?1:0;
  503.         // kjethi
  504.         $this->responseArray['productAdvertiseData'] = $this->productDetailManager->getAdvertiseForFrontByRefId($productId'product'); // $productId
  505.         if(array_key_exists('breadcrumbs',$this->responseArray) && array_key_exists('productAdvertiseData',$this->responseArray)){
  506.             if (count($this->responseArray['productAdvertiseData']) == && count($this->responseArray['breadcrumbs']) > 0) {
  507.                 $catForAdvertise array_keys($this->responseArray['breadcrumbs'])[0];
  508.                 if ($catForAdvertise 0) {
  509.                     $this->responseArray['productAdvertiseData'] = $this->productDetailManager->getAdvertiseForFrontByRefId($catForAdvertise'category'); //
  510.                 }
  511.             }
  512.         }
  513.         
  514.         // Other Product
  515.         $mainSku $this->responseArray['basic_information']['sku_number'] ? $this->responseArray['basic_information']['sku_number']:0;
  516.         if(strpos($this->responseArray['basic_information']['sku_number'], '-') != false){
  517.             $mainSku explode('-'$this->responseArray['basic_information']['sku_number'])[1]; // get main sku
  518.         }
  519.         if(isset($this->responseArray['other_products']) && is_array($this->responseArray['other_products'])){
  520.             $sortOrder = array($mainSku'80-'.$mainSku'75-'.$mainSku'76-'.$mainSku'81-'.$mainSku'82-'.$mainSku'86-'.$mainSku'10-'.$mainSku'42-'.$mainSku'20-'.$mainSku'28-'.$mainSku'25-'.$mainSku);
  521.             usort($this->responseArray['other_products'], function ($a$b) use ($sortOrder) {
  522.                 $pos_a array_search($a['sku_number'], $sortOrder);
  523.                 $pos_b array_search($b['sku_number'], $sortOrder);
  524.                 return $pos_a $pos_b;
  525.             });
  526.             
  527.         }
  528.         else{
  529.             $this->responseArray['other_products'] = null;
  530.         }
  531.         
  532.         $sku $this->responseArray['basic_information']['sku_number'] ? $this->responseArray['basic_information']['sku_number']:0;
  533.         $search_skus = [];
  534.         $globalConnectPrefixes = ['20''28''25'];
  535.         $isGlobalConnect 0;
  536.         if (strpos($sku'-') !== false) {
  537.             list($prefix$sku) = explode('-'$sku);
  538.             if($prefix == '80'){
  539.                 $search_skus = ['28-'.$sku'20-'.$sku'25-'.$sku];
  540.                 
  541.                 if($this->responseArray['isUsaConnect'] == 1){
  542.                     $this->responseArray["color_label"] ="Current Stock";
  543.                     $this->responseArray["color_label_1"] ="USA Connect";
  544.                 }
  545.                 else{
  546.                     $this->responseArray["color_label"] ="Domestic Stock";
  547.                     $this->responseArray["color_label_1"] ="Global Connect";
  548.                 }
  549.             }
  550.             elseif($prefix == '75'){
  551.                 $search_skus = ['25-'.$sku'20-'.$sku'28-'.$sku];
  552.                 
  553.                 if($this->responseArray['isUsaConnect'] == 1){
  554.                     $this->responseArray["color_label"] ="Current Stock";
  555.                     $this->responseArray["color_label_1"] ="USA Connect";
  556.                 }
  557.                 else{
  558.                     $this->responseArray["color_label"] ="Domestic Stock";
  559.                     $this->responseArray["color_label_1"] ="Global Connect";
  560.                 }
  561.             }
  562.             elseif($prefix == '20'){
  563.                 $isGlobalConnect 1;
  564.                 $search_skus = [$sku'80-' $sku];
  565.                 if($this->responseArray['isUsaConnect'] == 1){
  566.                     $this->responseArray["color_label_1"] ="Current Stock";
  567.                     $this->responseArray["color_label"] ="USA Connect";
  568.                 }
  569.                 else{
  570.                     $this->responseArray["color_label_1"] ="Domestic Stock";
  571.                     $this->responseArray["color_label"] ="Global Connect";
  572.                 }
  573.                 
  574.             }
  575.             elseif($prefix == '28'){
  576.                 $isGlobalConnect 1;
  577.                 $search_skus = ['80-' $sku$sku];
  578.                 if($this->responseArray['isUsaConnect'] == 1){
  579.                     $this->responseArray["color_label_1"] ="Current Stock";
  580.                     $this->responseArray["color_label"] ="USA Connect";
  581.                 }
  582.                 else{
  583.                     $this->responseArray["color_label_1"] ="Domestic Stock";
  584.                     $this->responseArray["color_label"] ="Global Connect";
  585.                 }
  586.                 
  587.             }
  588.             elseif($prefix == '25'){
  589.                 $isGlobalConnect 1;
  590.                 $search_skus = ['75-' $sku$sku'80-' $sku];
  591.                 if($this->responseArray['isUsaConnect'] == 1){
  592.                     $this->responseArray["color_label_1"] ="Current Stock";
  593.                     $this->responseArray["color_label"] ="USA Connect";
  594.                 }
  595.                 else{
  596.                     $this->responseArray["color_label_1"] ="Domestic Stock";
  597.                     $this->responseArray["color_label"] ="Global Connect";
  598.                 }
  599.                 
  600.             }
  601.             else{
  602.                 $search_skus = ['20-' $sku'28-' $sku'25-' $sku];
  603.                 
  604.                 if($this->responseArray['isUsaConnect'] == 1){
  605.                     $this->responseArray["color_label_1"] ="Current Stock";
  606.                     $this->responseArray["color_label"] ="USA Connect";
  607.                 }
  608.                 else{
  609.                     $this->responseArray["color_label_1"] ="Domestic Stock";
  610.                     $this->responseArray["color_label"] ="Global Connect";
  611.                 }
  612.             }
  613.         }else{
  614.             $search_skus null;
  615.             foreach($globalConnectPrefixes as $value){
  616.                 $search_skus[] = $value.'-'.$sku;
  617.             }
  618.             
  619.             if($this->responseArray['isUsaConnect'] == 1){
  620.                 $this->responseArray["color_label"] ="Current Stock";
  621.                 $this->responseArray["color_label_1"] ="USA Connect";
  622.             }
  623.             else{
  624.                 $this->responseArray["color_label"] ="Domestic Stock";
  625.                 $this->responseArray["color_label_1"] ="Global Connect";
  626.             }
  627.         }
  628.         // $productDetailArray = $this->solrProductManager->getProductDetailBySku($sku,$this->cultureCode,$this->responseArray['supplier']['supplier_id'],true,true);
  629.         $this->responseArray["otherProducts"] = array();//$productDetailArray;
  630.         
  631.         // $productTagManager = $this->serviceContainer->get('office_brain_product_tag_manager');
  632.         $productTagManager $this->productTagManager;
  633.         // $productTagManager = $this->get('office_brain_private_tag_extended');
  634.         $this->responseArray["laserProducts"] = $productTagManager->getAllImprintProducts();
  635.         $this->responseArray["laserProducts"] = array_column($this->responseArray["laserProducts"],'imprintMethod','productId');
  636.         
  637.        
  638.         $productHasGlobalConnect 0;
  639.         foreach($globalConnectPrefixes as $globalPrefix){
  640.             $key array_search($globalPrefix.'-'.$mainSkuarray_column($this->responseArray['other_products'], 'sku_number'));
  641.             if($key !== false){
  642.                 $productHasGlobalConnect 1;
  643.                 break;
  644.             }
  645.                 
  646.         }
  647.         $matching_products null;
  648.         
  649.         foreach ($search_skus as $sku) {
  650.             $matching_products array_filter($this->responseArray['other_products'], function($product) use ($sku) {
  651.                 return $product['sku_number'] === $sku;
  652.             });
  653.             if (!empty($matching_products)) {
  654.                 break; // Stop searching if a matching product is found
  655.             }
  656.         }
  657.             // Convert the filtered result into a simple indexed array
  658.         $matching_products array_values($matching_products);
  659.         $this->responseArray["matching_products"] = $matching_products;
  660.         $this->responseArray["main_image_url"] = $request->get('main_image_url');
  661.         $this->responseArray["is_global_connect"] =  $isGlobalConnect;
  662.         $this->responseArray["has_global_connect"] = $productHasGlobalConnect;
  663.         return $this->responseArray;
  664.     }
  665.     /**
  666.      *
  667.      * @author Employee Id: 4464
  668.      *         Desciption: Related Product Information.
  669.      *        
  670.      * @param
  671.      *            integer product id
  672.      *            
  673.      * @return product related information
  674.      *        
  675.      * @Route("/custom-related-product/{productId}",
  676.      *     name="officebrain_custom_bundle_product_bundle_product_relatedproduct",
  677.      * )
  678.      *
  679.      * @Template("OfficeBrain/Bundle/ProductBundle/Product/relatedProduct.html.twig")
  680.      *
  681.      */
  682.     public function customRelatedProductAction(Request $request)
  683.     {
  684.         $this->initAction($request);
  685.         $productId $this->request->get('productId'null);
  686.         $locale $this->request->getLocale();
  687.         // -----------------------------------------------------------------------
  688.         $cacheSiteKey = array(
  689.             $this->moduleCachePrefix,
  690.             $locale,
  691.             "id#" $productId,
  692.             $this->projectSetting['instance_id'],
  693.             $this->projectSetting['kernelEnvironment']
  694.             // $this->container->getParameter('kernel.environment') // symfony 4
  695.         );
  696.         $cacheKey RedisCacheService::generateKey($this->statsh_cache_wrapper$cacheSiteKey);
  697.         $cacheData RedisCacheService::getCacheData($this->statsh_cache_wrapper$cacheKey);
  698.         if ($cacheData) {
  699.             return $cacheData;
  700.         }
  701.         // -----------------------------------------------------------------------
  702.         $comproductreletedid $this->productApiManager->productreletedid($productId);
  703.         foreach ($comproductreletedid as $releted_productid) {
  704.             $relatedProductInfo $this->productDetailManager->getProductDetailById($releted_productid['relatedProductId'], $releted_productid['culture']);
  705.             $this->responseArray['related_product'][] = isset($relatedProductInfo[$releted_productid['relatedProductId']]);
  706.         }
  707.         if (! empty($cacheKey)) {
  708.             RedisCacheService::saveCacheData($this->statsh_cache_wrapper$cacheKey$this->responseArray);
  709.         }
  710.         return $this->responseArray;
  711.     }
  712.     /**
  713.      *
  714.      * @author Employee Id: 5633
  715.      *         Description : Use to show the list of product in this request quote.
  716.      * @param
  717.      *            1 : No paramater
  718.      * @return type : json
  719.      * @throws Exception: Null
  720.      *        
  721.      * @Route("/product-imprint-color-chart",
  722.      * name="officebrain_custom_product_bundle_imprint_custom_color",
  723.      * options={"expose"=true}
  724.      * )
  725.      * @Template("project/OfficeBrain/CustomBundle/ProductBundle/Product/imprintColorCustomChart.html.twig")
  726.      *
  727.      */
  728.     public function selectCustomColorAction(Request $request)
  729.     {
  730.         $this->initAction($request);
  731.         $product_id $this->request->get('product_id');
  732.         $culture $this->cultureCode;
  733.         $standardImprintColor $this->productDetailManager->getStandardImprintColorInformation($product_id$culture); 
  734.         $this->responseArray $this->productDetailManager->getProductDetailById($product_id$culture);
  735.         $this->responseArray['imprint_color_msg'] = 0;
  736.         if (isset($this->responseArray[$product_id]['basic_information']['sku_number']) && ! empty($this->responseArray[$product_id]['basic_information']['sku_number'])) {
  737.             $impintMsgArray $this->serviceContainer->getParameter('imprint_color_msg');
  738.             if (in_array($this->responseArray[$product_id]['basic_information']['sku_number'], $impintMsgArray)) {
  739.                 $this->responseArray['imprint_color_msg'] = 1;
  740.             }
  741.         }
  742.         return array(
  743.             'standard_imprint_color' => $standardImprintColor,
  744.             'imprint_color_msg' => $this->responseArray['imprint_color_msg']
  745.         );
  746.     }
  747.     /**
  748.      *
  749.      * @author Employee Id: 5429
  750.      *        
  751.      * @Route("/image-library/{page}",name="officebrain_custom_bundle_product_bundle_image_library",
  752.      * requirements={"records_per_page"="12|24|48|100|996","page"="\d+"},
  753.      * defaults={"records_per_page"=20,"page"=1}),
  754.      * @Template("project/OfficeBrain/CustomBundle/ProductBundle/Product/imageLibrary.html.twig")
  755.      *
  756.      */
  757.     public function imageLibraryAction(Request $request)
  758.     {
  759.         $this->initAction($request);
  760.         if ($this->userId == 0) {
  761.             return $this->redirect($this->generateUrl('office_brain_userbundle_login_login'));
  762.         }
  763.         $culture $this->cultureCode;
  764.         list ($cultureName[], $country[]) = explode("_"$culture);
  765.         $category $this->productDetailManager->getCategoryMapping();
  766.         $masterIds array_column($category'pms_id');
  767.         $params = array(
  768.             'cultures' => json_encode($cultureName),
  769.             'master_id' => json_encode($masterIds)
  770.         );
  771.         $this->categoryApi->init('list_category');
  772.         $this->categoryApi->setCallParameters($params);
  773.         $this->categoryApi->doProcess();
  774.         $data $this->categoryApi->getResultArray();
  775.         foreach ($category as $key) {
  776.             if (array_key_exists($key['pms_id'], $data['en'])) {
  777.                 $data['en'][$key['pms_id']]['parentid'] = $key['parentid'];
  778.                 $data['en'][$key['pms_id']]['haschildid'] = $key['haschildid'];
  779.             }
  780.         }
  781.         return $data;
  782.     }
  783.     /**
  784.      *
  785.      * @author Employee Id: 5429
  786.      *        
  787.      *         Description : This function used for List Product Information
  788.      * @Route("/product/view-psa-special/",name="officebrain_custombundle_productbundle_psaSpecial_view")
  789.      * @Template("project/OfficeBrain/CustomBundle/ProductBundle/Product/viewPsaSpecial.html.twig")
  790.      *
  791.      *
  792.      */
  793.     public function viewPsaSpecialAction(Request $request)
  794.     {
  795.         $this->initAction($request);
  796.         $imagename['path'] = $this->request->get('product_id''');
  797.         return $imagename;
  798.     }
  799.     /**
  800.      *
  801.      * @author Employee Id: 5429
  802.      *        
  803.      * @Route("/product/QRcode/view/{slug}",name="officebrain_custombundle_productbundle_qrcode_view", methods={"GET"}),
  804.      * @Template("project/OfficeBrain/CustomBundle/ProductBundle/Product/viewQRCode.html.twig")
  805.      *
  806.      */
  807.     public function viewQRCodeAction(Request $request$slug)
  808.     {
  809.         $this->initAction($request);
  810.         return $this->productDetailManager->getQRCodedetail($slug);
  811.     }
  812.     /**
  813.      *
  814.      * @author Employee Id: 4217
  815.      *        
  816.      *         Desciption: Virtual Tool
  817.      *        
  818.      * @param
  819.      *            video_url.
  820.      *            
  821.      * @return json Response
  822.      *        
  823.      * @Route("/product-virtual-tool",
  824.      *     name="officebrain_product_bundle_product_virtual_tool"
  825.      * )
  826.      *
  827.      * @Template("OfficeBrain/Bundle/ProductBundle/Product/productVirtualTool.html.twig")
  828.      */
  829.     public function productVirtualToolAction(Request $request)
  830.     {
  831.         $this->initAction($request);
  832.         $itemNo $this->request->get("itemno");
  833.         $prodctid $this->request->get("prodctid");
  834.         $this->responseArray['productSku'] = $itemNo;
  835.         return $this->responseArray;
  836.     }
  837.     /**
  838.      *
  839.      * @author Employee Id: 5429
  840.      *        
  841.      * @Route("/product/email-factory-for-price/{product_id}",name="officebrain_custombundle_productbundle_email_factory_for_price", methods={"GET","POST"}),
  842.      *
  843.      */
  844.     public function emailFactoryForPriceAction(Request $request)
  845.     {
  846.         $this->initAction($request);
  847.         $productId $this->request->get('product_id');
  848.         $productDetailArrayId $this->productDetailManager->getProductDetailById($productId$this->cultureCode);
  849.         if (isset($productDetailArrayId[$productId]) && ! empty($productDetailArrayId[$productId])) {
  850.             $itemName = isset($productDetailArrayId[$productId]['basic_information']['title']) ? $productDetailArrayId[$productId]['basic_information']['title'] : "";
  851.             $skuNumber = isset($productDetailArrayId[$productId]['basic_information']['sku_number']) ? $productDetailArrayId[$productId]['basic_information']['sku_number'] : "";
  852.             $imprintColors "";
  853.             $notes "";
  854.             if ($productDetailArrayId[$productId]['feature_details']) {
  855.                 foreach ($productDetailArrayId[$productId]['feature_details'] as $features) {
  856.                     if (strtolower(trim($features['label'])) == "imprint colors") {
  857.                         $imprintColors $features['value'];
  858.                     }
  859.                     if (strtolower($features['label']) == "note") {
  860.                         $notes $features['value'];
  861.                     }
  862.                 }
  863.             }
  864.             $quantity = array();
  865.             if ($productDetailArrayId[$productId]['pricing']['decorative']) {
  866.                 foreach ($productDetailArrayId[$productId]['pricing']['decorative'] as $pricing) {
  867.                     $priceTo = ! empty($pricing['to']) ? "-" $pricing['to'] : "+";
  868.                     $quantity[] = $pricing['from'] . $priceTo;
  869.                 }
  870.             }
  871.             $quantity implode("|"$quantity);
  872.             $eventKey 'productDetailFactoryPriceEmail';
  873.             $to ""// "jrathod@officebrain.com";//specialquotes@aakronline.com
  874.             $languageId $this->languageId;
  875.             $subject "Test Email";
  876.             $params = array(
  877.                 'item_name' => $itemName,
  878.                 'sku_number' => $skuNumber,
  879.                 'quantity' => $quantity,
  880.                 'imprint_color' => $imprintColors,
  881.                 'additional_notes' => $notes
  882.             );
  883.             $from ""// "jrathod@officebrain.com";
  884.             $attachment = array();
  885.             $cc ''// array();
  886.             $bcc ''// array();
  887.             $this->emailService->sendMail($eventKey$to$params$languageId$from$subject$attachment$cc$bcc);
  888.             $this->responseArray['status'] = 'success';
  889.             $this->responseArray['success_message'] = $this->translator->trans('email.success');
  890.         } else {
  891.             $this->responseArray['status'] = 'error';
  892.             $this->responseArray['error_message'] = "There is some issue please try again later!";
  893.         }
  894.         return new JsonResponse($this->responseArray);
  895.     }
  896.     /**
  897.      *
  898.      * @author(Kjethi)
  899.      * @Route("/suggested-product/{productId}",
  900.      *     name="office_brain_search_bundle_product_suggested_product_list",
  901.      * )
  902.      * @Template("project/OfficeBrain/CustomBundle/SearchBundle/BrowseCategory/suggestedProduct.html.twig")
  903.      */
  904.     public function getSuggestedProductByProductAction(Request $request$productId$category = [])
  905.     {
  906.         $this->initAction($request);
  907.         $productId $productId;
  908.         // $searchManager = $this->get('office_brain_custom_bundle_search_manager'); // symfony 4
  909.         // $searchManager = $this->serviceContainer->get('office_brain_search_manager_extended');
  910.         $searchManager $this->searchManager;
  911.         $suggestedProductData = array();
  912.         $data $this->productApiManager->getSuggestedProductByProductId($productId);
  913.         if (isset($data['suggestedProducts']) && count($data['suggestedProducts']) > 0) {
  914.             $suggestedProductData $data['suggestedProducts'];
  915.         } else if (count($category) > 0) {
  916.             $api_manager $this->serviceContainer->get('officebrain_category_api_manager');
  917.             $categoryWiseSuggestedArr $api_manager->getSuggestedProductByRelatedCat($category[0]);
  918.             $categoryWiseSuggestedArr array_column($categoryWiseSuggestedArr'suggestedProduct');
  919.             $suggestedProductData '';
  920.             foreach ($categoryWiseSuggestedArr as $suggProductIdArr) {
  921.                 $suggestedProductData .= ($suggestedProductData ',' '') . $suggProductIdArr// array_filter - remove blank element
  922.             }
  923.             $suggestedProductData explode(','$suggestedProductData);
  924.             $suggestedProductData array_filter($suggestedProductData);
  925.         }
  926.         // $api_manager = $this->get('officebrain_category_api_manager');
  927.         // $categoryWiseSuggestedArr= $api_manager->getSuggestedProductByRelatedCat($category);
  928.         // $categoryWiseSuggestedArr= array_column($categoryWiseSuggestedArr, 'suggestedProduct');
  929.         // $suggestedProductData='';
  930.         // foreach ($categoryWiseSuggestedArr as $suggProductIdArr){
  931.         // $suggestedProductData .= ($suggestedProductData ? ',': '' ).$suggProductIdArr;//array_filter - remove blank element
  932.         // }
  933.         // $suggestedProductData = explode(',',$suggestedProductData);
  934.         // $suggestedProductData = array_filter($suggestedProductData);
  935.         // /////////////////////////////////////
  936.         // $data = $this->productApiManager->getSuggestedProductByProductId($productId);
  937.         $suggestedProductData array_merge($suggestedProductData$data['suggestedProducts']);
  938.         if ($data && count($suggestedProductData) > 0) {
  939.             $result = array();
  940.             if (count($suggestedProductData))
  941.                 $sku $suggestedProductData// implode($data['suggestedProducts'], ',');
  942.                                               // $sku = $data['suggestedProducts'];//
  943.             $this->request->query->set('sku'$sku);
  944.             $this->request->query->set('search_type''exact');
  945.             // this is for remove By Default soring(which is Price:desc)
  946.             $this->request->query->set('sort_by''1');
  947.             $this->responseArray $searchManager->searchService(true);
  948.             $data = array();
  949.             // $data = $this->site_module->getProduct($criteria);
  950.             # print_r(array_keys((array)$this->responseArray['search_result_array']));
  951.             # echo(array_keys($this->responseArray['search_result_array']));exit;
  952.             // print_r($this->responseArray);exit;
  953.             $data['search_result_array'] = $this->responseArray['search_result_array'];
  954.             // print_r(array_keys($data['search_result_array']));exit;
  955.             $data['product_box_bootstrap_class'] = 'item';
  956.             $data['render_model'] = 0;
  957.             // echo "<pre>"; dump($data['search_result_array']); exit;
  958.             // return $this->render('OfficeBrainPageBundle:tempUIElements:recommendProducts.html.twig', $data);
  959.             $response $this->render("project/OfficeBrain/CustomBundle/SearchBundle/BrowseCategory/suggestedProduct.html.twig"$data);
  960.             if(!empty($cacheKey))
  961.             {
  962.               RedisCacheService::saveCacheData($this->statsh_cache_wrapper,$cacheKey,$response);
  963.             }
  964.             return $response;
  965.         }
  966.         else{
  967.             return array();
  968.         }
  969.         
  970.     }
  971.     
  972.     /**
  973.      * @author Employee Id: 6799
  974.      *
  975.      * Description : This function used for Get information about ESP
  976.      * @Route("/get-esp-data/{productSku}",name="officebrain_custombundle_productbundle_getespdata")
  977.      * @return json Response
  978.      *
  979.      */
  980.     public function getEspDataAction(Request $request)
  981.     {
  982.         $this->initAction($request);
  983.         $productSku $this->request->get("productSku");
  984.         $selectedData $this->productDetailManager->getEspProductData($productSku);
  985.         $responseData null;
  986.         if($selectedData){
  987.             $responseData["selected_esp_product_type"] = $selectedData->getEspProductType();
  988.             $responseData["selected_esp_categories"] = $selectedData->getEspProductCategory();
  989.         }
  990.         $response = new Response(json_encode($responseData));
  991.         $response->headers->set('Content-Type''application/json');
  992.         $response->headers->set('X-Status-Code'404);
  993.         return $response;
  994.     }
  995.     
  996.     
  997.     /**
  998.      *
  999.      * @author Employee Id: Freelancer
  1000.      * @param
  1001.      * @return type : json
  1002.      * @throws Exception: Null
  1003.      *
  1004.      * @Route("/product-hts-code",
  1005.      * name="officebrain_custom_product_bundle_hts_code",
  1006.      * options={"expose"=true}
  1007.      * )
  1008.      * @Template("project/OfficeBrain/CustomBundle/ProductBundle/Product/productHtsCode.html.twig")
  1009.      *
  1010.      */
  1011.     public function productHtsCodeAction(Request $request)
  1012.     {
  1013.         $this->initAction($request);
  1014.         $product_id $this->request->get('product_id');
  1015.         $culture $this->cultureCode;
  1016.         
  1017.         $productDetailArray $this->productDetailManager->getProductDetailById($product_id$culture);
  1018.         
  1019.         $this->responseArray $productDetailArray[$product_id];
  1020.         
  1021.         $this->responseArray['data'] = $this->responseArray['feature_details'];
  1022.         
  1023.         return $this->responseArray;
  1024.     }
  1025.     /**
  1026.      * @author Vendor
  1027.      *
  1028.      * Description : This function used for update Product Price
  1029.      * @return array
  1030.      * @Route("/product/update-tiory-price/{sku}", name="officebrain_product_update_product_pricing"),
  1031.      */
  1032.     public function updateProductPricingAction(Request $request$sku){
  1033.         $this->initAction($request);
  1034.         $mainSku $sku;
  1035.         // $data=$this->request->all();
  1036.         $pricingYear $this->request->get('price_year'date("Y"));
  1037.         $prefixSku substr($sku,0,2);
  1038.         $hasPrefixSku false;
  1039.         if(in_array($prefixSku,["10","20","80","81","82""75""76""25""28"])){
  1040.             $hasPrefixSku true;
  1041.             $prefixSku substr($sku,0,2);
  1042.             $m_sku substr($sku,2);
  1043.             $sku $prefixSku."-"$m_sku;
  1044.         }
  1045.         
  1046.         $projectSetting $this->request->get('project_setting');
  1047. //         $sku = $this->request->get('sku', '');
  1048.         //         $masterProductId = $this->request->get('master_product_id', '');
  1049.         $countryArray $this->serviceContainer->getParameter('country');
  1050.         $languageArray $this->serviceContainer->getParameter('language');
  1051.         $country_to_pass array_column($countryArray,'short_name');
  1052.         $language_to_pass array_keys($languageArray);
  1053.         $param $this->request->get('_route_params');
  1054.         $locale_language $param['_locale'];
  1055.         $locale $this->request->get('_locale',$this->serviceContainer->getParameter('locale'));
  1056.         @list($default_language,$default_country) = explode("_",$locale);
  1057.         $cultureName $this->projectSetting['culture_code'];
  1058.         
  1059.         
  1060.         $supplier_id 0;
  1061.         // set global_pricing_keys which are active
  1062.         
  1063.         
  1064.         if($sku){
  1065.             
  1066.             $tioryPriceData $this->callTioryPriceApiFromSku($mainSku$pricingYear);
  1067.             
  1068.             //             echo "<pre>";print_r($tioryPriceData["BodyData"]["PriceData"]);exit;
  1069.             
  1070.             if($tioryPriceData["status"] != "success"){
  1071.                 $response = array('status' => "error",'error_message'=>"Tiory price not found");
  1072.                 return new JsonResponse($response);
  1073.             }
  1074.             $withPrefix0 false;
  1075.             do {
  1076.                 $productInfoFromSku $this->productDetailManager->getProductDetailBySku($sku,5,$cultureName);
  1077.                 if(isset($productInfoFromSku["product_id"]) || substr($sku,0,1) == "0"){
  1078.                     $withPrefix0 true;
  1079.                 }
  1080.                 else {
  1081.                     $sku "0".$sku;
  1082.                 }
  1083.             } while (!$withPrefix0);
  1084.             
  1085.             // need to check because sku has sometime prefix number in mainSku like (2020)
  1086.             if(!isset($productInfoFromSku["product_id"]) && $hasPrefixSku){                
  1087.                 $withPrefix0 false;
  1088.                 $sku $mainSku;
  1089.                 do {
  1090.                     $productInfoFromSku $this->productDetailManager->getProductDetailBySku($sku,5,$cultureName);
  1091.                     if(isset($productInfoFromSku["product_id"]) || substr($sku,0,1) == "0"){
  1092.                         $withPrefix0 true;
  1093.                     }
  1094.                     else {
  1095.                         $sku "0".$sku;
  1096.                     }
  1097.                 } while (!$withPrefix0);
  1098.             }
  1099.             
  1100.             if(isset($productInfoFromSku["product_id"])){
  1101.                 $masterProductId $productInfoFromSku["product_id"];
  1102.                 $productInfo $this->productApiManager->editView($masterProductId,$language_to_pass,$country_to_pass,$default_language);
  1103.                 //             $masterProductId
  1104.                 //         echo "<pre>";print_r($productInfo);exit;
  1105.                 
  1106.                 $updateProductArr $this->setProductDataAsPerUpdate($productInfo,$default_country,$default_language,$tioryPriceData["BodyData"]["PriceData"]);
  1107.                 
  1108.                 
  1109.                 $apiResponse $this->productApiManager->add($cultureName$updateProductArr);
  1110.                 if ($apiResponse['status']=='success') {
  1111.                     $response = array('status' => $apiResponse['status'],'success_message'=>$this->get('translator')->trans($apiResponse['success_message']));
  1112.                     
  1113.                     $actionPerformed 'update';
  1114.                     
  1115.                     //SOLR SYNC CODE START
  1116.                     $is_solr_syn_enabled $this->serviceContainer->getParameter('solr_sync');
  1117.                     if($is_solr_syn_enabled){
  1118.                         $env $this->serviceContainer->getParameter("kernel.environment");
  1119.                         $localization_to_update $this->serviceContainer->getParameter('localization_to_fetch');
  1120.                         $this->productApiManager->updateSolrData($apiResponse['master_product_id'],$localization_to_update,$projectSetting['project_id'],$env,'update');
  1121.                     }
  1122.                     
  1123.                     //SOLR SYNC CODE END
  1124.                     
  1125.                     // To Integrate With ERP
  1126.                     $erpIntegration $projectSetting['configuration_rule']['erp_integration'];
  1127.                     if($erpIntegration && $erpIntegration['productManagement'] == && !empty($this->queueApiManager)) {
  1128.                         $this->productApiManager->integrateWithErp($this->queueApiManager$actionPerformed$apiResponse['master_product_id']);
  1129.                     }
  1130.                     if($this->request->get('syncflag')==1){
  1131.                         if($productAddSettings['asi_call']['status']){
  1132.                             foreach ($apiResponse['product_slugs'] as $culture => $slug){
  1133.                                 if($masterProductId 0)
  1134.                                 {
  1135.                                     $this->productDetailManager->updateSyncDetail($this->request->get('syncflag'),$updateProductArr['sku']);
  1136.                                     $asiurl 'http://demoapi.officebrain.com/update_product_api.php?product_slug='.$slug;
  1137.                                 }
  1138.                                 else
  1139.                                 {
  1140.                                     $this->productDetailManager->insertSyncDetail($this->request->get('syncflag'),$updateProductArr['sku']);
  1141.                                     $asiurl 'http://demoapi.officebrain.com/product_api.php?product_slug='.$slug;
  1142.                                 }
  1143.                                 //echo $asiurl;die;
  1144.                                 exec("curl '$asiurl' > /dev/null &");
  1145.                             }
  1146.                         }
  1147.                     }
  1148.                     else
  1149.                     {
  1150.                         if($masterProductId 0)
  1151.                         {
  1152.                             $this->productDetailManager->updateSyncDetail(0,$updateProductArr['sku']);
  1153.                         }
  1154.                         else
  1155.                         {
  1156.                             $this->productDetailManager->insertSyncDetail(0,$updateProductArr['sku']);
  1157.                         }
  1158.                         
  1159.                         if(isset($updateProductArr['sku']) && !empty($updateProductArr['sku'])){
  1160.                             $asiurl 'http://demoapi.officebrain.com/product_delete_api.php?product_sku='.$updateProductArr['sku'];
  1161.                             exec("curl '$asiurl' > /dev/null &");
  1162.                         }
  1163.                     }
  1164.                 }
  1165.                 
  1166.                 return new JsonResponse($response);;
  1167.             }
  1168.             
  1169.             
  1170.         }
  1171.         $response = array('status' => "error",'error_message'=>"Product not found");
  1172.         return new JsonResponse($response);;
  1173.     }
  1174.     function setProductDataAsPerUpdate($productInfo,$default_country,$default_language,$tioryPriceData){
  1175.         $param $this->request->get('_route_params');
  1176.         $projectSetting $this->request->get('project_setting');
  1177.         $locale_language $param['_locale'];
  1178.         $countryArray $this->serviceContainer->getParameter('country');
  1179.         $productAddSettings $projectSetting['configuration_rule']['product']['add_update'];
  1180.         $globalPricingKeys '';
  1181.         if(array_key_exists('global_pricing'$productAddSettings))
  1182.         {
  1183.             foreach ($productAddSettings['global_pricing'] as $key => $val)
  1184.             {
  1185.                 if ($val['status'] == 1)
  1186.                 {
  1187.                     $globalPricingKeys .= ($val['pricing_box_id'].':'.$val['pricing_box_name']).',';
  1188.                 }
  1189.             }
  1190.         }
  1191.         $productBasicInfo $productInfo[$default_language]["basic_information"];
  1192.         $updateProductArr = array();
  1193.         $updateProductArr["master_product_id"] = $productInfo["product_id"];
  1194.         $updateProductArr["supplier_id"] = $productInfo["supplier_id"];
  1195.         $updateProductArr["product_source"] = $productInfo["product_source"];
  1196.         $updateProductArr["sku"] = $productBasicInfo["sku_number"];
  1197.         $updateProductArr["product_name"] = array(
  1198.             $default_language => $productBasicInfo["title"]
  1199.         );
  1200.         $updateProductArr["country"] = array(
  1201.             ($countryArray[$default_country]["id"]) ."_"$default_country
  1202.         );
  1203.         $updateProductArr["lang"] = array(
  1204.             $default_country => array($default_language)
  1205.         );
  1206.         $updateProductArr["brand"] = $productInfo["brand"]["id"];
  1207.         $updateProductArr["category"] = array(
  1208.             "country_".$default_country => $productInfo["category"][$default_country]
  1209.         );
  1210.         
  1211.         $updateProductArr["product_description"] = array(
  1212.             $default_language => $productBasicInfo["description"]
  1213.         );
  1214.         $updateProductArr["feature_detail_label"] = array(
  1215.             $default_language => array_column($productInfo[$default_language]["feature_details"],"label")
  1216.         );
  1217.         $updateProductArr["feature_detail"] = array(
  1218.             $default_language => array_column($productInfo[$default_language]["feature_details"],"value")
  1219.         );
  1220.         $updateProductArr["keyword"] = array(
  1221.             $default_language => $productInfo[$default_language]["keyword"]
  1222.         );
  1223.         $updateProductArr["video_url"] = $productBasicInfo["video_url"];
  1224.         $updateProductArr["distributor_central_url"] = $productBasicInfo["distributor_url"];
  1225.         $updateProductArr["details_attribute_to_add"] = array_column($productInfo["attributes"],"attribute_id");
  1226.         
  1227.         $tmpDetaiAndValues array_reduce($productInfo["attributes_values"][$default_country], function($carry$item){
  1228.             if(!isset($carry[$item['attribute_id']])){
  1229.                 $carry[$item['attribute_id']] = array();
  1230.             }
  1231.             array_push($carry[$item['attribute_id']],$item['attribute_val']);
  1232.             return $carry;
  1233.         });
  1234.             $updateProductArr["DetailsAndValue"] = array(
  1235.                 "country_".$default_country => array_map(function ($v){ return [implode(",",$v)]; },$tmpDetaiAndValues)
  1236.                 
  1237.             );
  1238.             $updateProductArr["PricingType"] = $productInfo["regular_variations_type"];
  1239.             
  1240.             function price($obj){
  1241.                 $a = array(
  1242.                     "start" => $obj["from"],
  1243.                     "end" => $obj["to"],
  1244.                     "price" => $obj["rate"],
  1245.                     "code" => $obj["code"],
  1246.                     "decorative_new_price" => "",
  1247.                     "decorative_new_code" => "",
  1248.                     "blank_price" => "",
  1249.                     "blank_code" => "",
  1250.                     "special_price" => "",
  1251.                     "special_code" => "",
  1252.                 );
  1253.             }
  1254.             $mainPriceArr = array();
  1255.             $regularPriceArr = array();
  1256.             $aboveCatalogPriceArr = array();
  1257.             foreach ($tioryPriceData as $k => $v) {
  1258.                 $end $k == count($tioryPriceData)-1  "" $tioryPriceData[$k+1]["quantity"]-1;
  1259.                 $tmpArr = array(
  1260.                     "start" => $v["quantity"],
  1261.                     "end" => $end,
  1262.                     'price' => $v["list"],
  1263.                     "code" => $v["price_discount_id"],
  1264.                     "decorative_new_price" => "",
  1265.                     "decorative_new_code" => "",
  1266.                     "blank_price" => "",
  1267.                     "blank_code" => "",
  1268.                     "special_price" => "",
  1269.                     "special_code" => ""
  1270.                 );
  1271.                 
  1272.                 array_push($mainPriceArr,$tmpArr);
  1273.                 if($k <= $v["eqp"]){
  1274.                     array_push($regularPriceArr,$tmpArr);
  1275.                 }
  1276.                 else if($v["eqp"]+>= $k){
  1277.                     array_push($aboveCatalogPriceArr,$tmpArr);
  1278.                 }
  1279.             }
  1280.             //             echo "<pre>";print_R($productBasicInfo);
  1281.             //             print_R($aboveCatalogPriceArr);exit;
  1282.             $updateProductArr["Pricing"] = array(
  1283.                 "price_unit" => $productInfo["regular_price_unit"],
  1284.                 "regular" => array(
  1285.                     "country_".$default_country => $regularPriceArr
  1286.                 )
  1287.             );
  1288.             $updateProductArr["pricing_valid_until"] = isset($productBasicInfo["pricing_valid_until"]) ? $productBasicInfo["pricing_valid_until"] : "";
  1289.             $updateProductArr["pricing_valid_starting"] = isset($productBasicInfo["pricing_valid_starting"]) ? $productBasicInfo["pricing_valid_starting"] :"";
  1290.             $updateProductArr["chk_global_pricing2"] = "pricing2";
  1291.             $updateProductArr["PricingType2"] = isset($productInfo["global_pricing"]["above_catalog"]) ? $productInfo["global_pricing"]["above_catalog"]["regular_variations_type"] : "";
  1292.             $updateProductArr["Pricing2"] = array(
  1293.                 "price_unit" => $productInfo["global_pricing"]["above_catalog"]["regular_price_unit"],
  1294.                 "regular" => array(
  1295.                     "country_".$default_country => $aboveCatalogPriceArr
  1296.                 )
  1297.             );
  1298.             $updateProductArr["general_information"] = array(
  1299.                 $default_language => $productBasicInfo["general_information"]
  1300.             );
  1301.             $updateProductArr["sample_pricing"] = array(
  1302.                 "country_".$default_country => array("price" => "","max_quantity" => "")
  1303.             );
  1304.             function prod_img_map($imgObj){
  1305.                 if(isset($imgObj["image_name"])){
  1306.                     return array($imgObj["image_name"], $imgObj["attr_val_id"]."::SEP::".$imgObj["attribute_value"]);
  1307.                 }
  1308.                 else {
  1309.                     array("");
  1310.                 }
  1311.             }
  1312.             $updateProductArr["image_product"] = array();
  1313.             if(isset($productInfo["prod_images"]["default_image"])){
  1314.                 $imgObj $productInfo["prod_images"]["default_image"];
  1315.                 $updateProductArr["image_product"]["default_image"] = array($imgObj["image_name"], $imgObj["attr_val_id"]."::SEP::".$imgObj["attribute_value"]);
  1316.             }
  1317.             if(isset($productInfo["prod_images"]["other"])){
  1318.                 foreach ($productInfo["prod_images"]["other"]  as $i => $imgObj){
  1319.                     if(isset($imgObj["image_name"])){
  1320.                         $otherKeyName "other_image";
  1321.                         if($i){
  1322.                             $otherKeyName $otherKeyName."_".$i;
  1323.                         }
  1324.                         $updateProductArr["image_product"][$otherKeyName] = array($imgObj["image_name"], $imgObj["attr_val_id"]."::SEP::".$imgObj["attribute_value"]);
  1325.                     }
  1326.                 }
  1327.             }
  1328.             //         $updateProductArr["image_product"] = array(
  1329.             //             "default_image" => array_map(function ($imgObj){
  1330.             //             if(isset($imgObj["image_name"])){
  1331.                 //                 return array($imgObj["image_name"], $imgObj["attr_val_id"]."::SEP::".$imgObj["attribute_value"]);
  1332.                 //             }
  1333.                 //             else {
  1334.                 //                 array("");
  1335.                 //             }
  1336.                 //         },$productInfo["prod_images"]["default_image"]),
  1337.                 //             "other_image" => array_map(function ($imgObj){
  1338.                 //             if(isset($imgObj["image_name"])){
  1339.                 //                 return array($imgObj["image_name"], $imgObj["attr_val_id"]."::SEP::".$imgObj["attribute_value"]);
  1340.                     //             }
  1341.                     //             else {
  1342.                     //                 array("");
  1343.                     //             }
  1344.                     //             },isset($productInfo["prod_images"]["other_image"]) ? $productInfo["prod_images"]["other_image"] : array() )
  1345.                     //         );
  1346.                     
  1347.                     $charges = array();
  1348.                     
  1349.                     function returnProperFormatChargePrice($priceArr){
  1350.                         if(is_array($priceArr)){
  1351.                             return array_map(function($v){
  1352.                                 return array(
  1353.                                     "start" => $v["from"],
  1354.                                     "end" => $v["to"],
  1355.                                     "price" => $v["rate"],
  1356.                                     "code" => $v["code"],
  1357.                                 );
  1358.                             }, $priceArr);
  1359.                         }
  1360.                         else {
  1361.                             return $priceArr;
  1362.                         }
  1363.                         
  1364.                     }
  1365.                     
  1366.                     foreach ($productInfo["imprint_method_information"] as $imprint_method_id => $value) {
  1367.                         //             echo "<pre>";print_r($value);exit;
  1368.                         # code...
  1369.                         
  1370.                         $chargesArr=array();
  1371.                         if(isset($value["charges"]["country_".$default_country]["LTM_CHARGE"])){
  1372.                             $chargesArr["LTM_CHARGE"] = array();
  1373.                             $chargesArr["LTM_CHARGE"]["charge"] = isset($value["charges"]["country_".$default_country]["LTM_CHARGE"]) ? $value["charges"]["country_".$default_country]["LTM_CHARGE"]["charge"] : "";
  1374.                             if(isset($value["charges"]["country_".$default_country]["LTM_CHARGE"]["code"])){
  1375.                                 $chargesArr["LTM_CHARGE"]["code"] = $value["charges"]["country_".$default_country]["LTM_CHARGE"]["code"];
  1376.                             }
  1377.                         };
  1378.                         if(isset($value["charges"]["country_".$default_country]["RUSH_CHARGE"])){
  1379.                             $chargesArr["RUSH_CHARGE"] = array();
  1380.                             $chargesArr["RUSH_CHARGE"]["charge"] = isset($value["charges"]["country_".$default_country]["RUSH_CHARGE"]) ? $value["charges"]["country_".$default_country]["RUSH_CHARGE"]["charge"] : "";
  1381.                             if(isset($value["charges"]["country_".$default_country]["RUSH_CHARGE"]["code"])){
  1382.                                 $chargesArr["RUSH_CHARGE"]["code"] = $value["charges"]["country_".$default_country]["RUSH_CHARGE"]["code"];
  1383.                             }
  1384.                         };
  1385.                         if(isset($value["charges"]["country_".$default_country]["PMS_CHARGE"])){
  1386.                             $chargesArr["PMS_CHARGE"] = array();
  1387.                             $chargesArr["PMS_CHARGE"]["charge"] = isset($value["charges"]["country_".$default_country]["PMS_CHARGE"]) ? $value["charges"]["country_".$default_country]["PMS_CHARGE"]["charge"] : "";
  1388.                             if(isset($value["charges"]["country_".$default_country]["PMS_CHARGE"]["code"])){
  1389.                                 $chargesArr["PMS_CHARGE"]["code"] = $value["charges"]["country_".$default_country]["PMS_CHARGE"]["code"];
  1390.                             }
  1391.                             
  1392.                         };
  1393.                         if(isset($value["charges"]["country_".$default_country]["SETUP_CHARGE"])){
  1394.                             $chargesArr["SETUP_CHARGE"] = array();
  1395.                             $chargesArr["SETUP_CHARGE"]["charge"] = returnProperFormatChargePrice($value["charges"]["country_".$default_country]["SETUP_CHARGE"]["charge"]);
  1396.                             if(isset($value["charges"]["country_".$default_country]["SETUP_CHARGE"]["code"])){
  1397.                                 $chargesArr["SETUP_CHARGE"]["code"] = $value["charges"]["country_".$default_country]["SETUP_CHARGE"]["code"];
  1398.                             } else {
  1399.                                 $chargesArr["SETUP_CHARGE"]["quantity_wise"] = "on";
  1400.                             }
  1401.                         };
  1402.                         if(isset($value["charges"]["country_".$default_country]["ADDITIONAL_LOCATION_CHARGE"])){
  1403.                             $chargesArr["ADDITIONAL_LOCATION_CHARGE"] = array();
  1404.                             $chargesArr["ADDITIONAL_LOCATION_CHARGE"]["charge"] = returnProperFormatChargePrice($value["charges"]["country_".$default_country]["ADDITIONAL_LOCATION_CHARGE"]["charge"]);
  1405.                             if(isset($value["charges"]["country_".$default_country]["ADDITIONAL_LOCATION_CHARGE"]["code"])){
  1406.                                 $chargesArr["ADDITIONAL_LOCATION_CHARGE"]["code"] = $value["charges"]["country_".$default_country]["ADDITIONAL_LOCATION_CHARGE"]["code"];
  1407.                             }
  1408.                             else {
  1409.                                 $chargesArr["ADDITIONAL_LOCATION_CHARGE"]["quantity_wise"] = "on";
  1410.                             }
  1411.                         };
  1412.                         if(isset($value["charges"]["country_".$default_country]["ADDITIONAL_COLOR_CHARGE"])){
  1413.                             $chargesArr["ADDITIONAL_COLOR_CHARGE"] = array();
  1414.                             if(isset($value["charges"]["country_".$default_country]["ADDITIONAL_COLOR_CHARGE"]["code"])){
  1415.                                 $chargesArr["ADDITIONAL_COLOR_CHARGE"]["code"] = $value["charges"]["country_".$default_country]["ADDITIONAL_COLOR_CHARGE"]["code"];
  1416.                             }
  1417.                             else {
  1418.                                 $chargesArr["ADDITIONAL_COLOR_CHARGE"]["quantity_wise"] = "on";
  1419.                             }
  1420.                             $chargesArr["ADDITIONAL_COLOR_CHARGE"]["charge"] =  returnProperFormatChargePrice($value["charges"]["country_".$default_country]["ADDITIONAL_COLOR_CHARGE"]["charge"]);
  1421.                             
  1422.                             
  1423.                             
  1424.                         };
  1425.                         
  1426.                         
  1427.                         $charges[$imprint_method_id] = array(
  1428.                             "position" => implode(",",array_keys($value["imprint_location"])),
  1429.                             "imprint_area" => $value["imprint_area"],
  1430.                             "color_included" => $value["color_included_in_price"],
  1431.                             "maximum_color" => $value["maximum_selectable_color"],
  1432.                             "location_included" => $value["location_included_in_price"],
  1433.                             "maximum_location" => $value["maximum_selectable_location"],
  1434.                             "production_days" => $value["production_days"],
  1435.                             "production_unit" => $value["production_unit"],
  1436.                             "country_".$default_country => $chargesArr
  1437.                         );
  1438.                     }
  1439.                     
  1440.                     $updateProductArr["imprint_information"] = array(
  1441.                         "method" => array_keys($productInfo["imprint_methods"]),
  1442.                         "charges" => $charges
  1443.                     );
  1444.                     $updateProductArr["shipping"] = array(
  1445.                         "fob" => $productInfo["shipping_information"]["free_on_board"],
  1446.                         "carton_quantity" => isset($productInfo["shipping_information"]["carton"]["quantity"]["param"]) ? $productInfo["shipping_information"]["carton"]["weight"]["param"] : "",
  1447.                         "carton_weight" => isset($productInfo["shipping_information"]["carton"]["weight"]["param"]) ? $productInfo["shipping_information"]["carton"]["weight"]["param"] : "",
  1448.                         "carton_weight_unit" => isset($productInfo["shipping_information"]["carton"]["weight"]["unit"]) ? $productInfo["shipping_information"]["carton"]["weight"]["unit"] : "",
  1449.                         "carton_length" => isset($productInfo["shipping_information"]["carton"]["length"]["param"]) ? $productInfo["shipping_information"]["carton"]["length"]["param"] : "",
  1450.                         "carton_width" => isset($productInfo["shipping_information"]["carton"]["width"]["param"]) ? $productInfo["shipping_information"]["carton"]["width"]["param"] : "",
  1451.                         "carton_height" => isset($productInfo["shipping_information"]["carton"]["height"]["param"]) ? $productInfo["shipping_information"]["carton"]["height"]["param"] : "",
  1452.                         "carton_size_unit" => isset($productInfo["shipping_information"]["carton"]["height"]["unit"]) ? $productInfo["shipping_information"]["carton"]["height"]["unit"] : "",
  1453.                         "product_weight" => isset($productInfo["shipping_information"]["product"]["weight"]["param"]) ? $productInfo["shipping_information"]["product"]["weight"]["param"] : "",
  1454.                         "product_weight_unit" => isset($productInfo["shipping_information"]["product"]["weight"]["unit"]) ? $productInfo["shipping_information"]["product"]["weight"]["unit"] : "",
  1455.                         "product_length" => isset($productInfo["shipping_information"]["product"]["length"]["param"]) ? $productInfo["shipping_information"]["product"]["length"]["param"] : "",
  1456.                         "product_width" => isset($productInfo["shipping_information"]["product"]["width"]["param"]) ? $productInfo["shipping_information"]["product"]["width"]["param"] : "",
  1457.                         "product_height" => isset($productInfo["shipping_information"]["product"]["height"]["param"]) ? $productInfo["shipping_information"]["product"]["height"]["param"] : "",
  1458.                         "product_size_unit" => isset($productInfo["shipping_information"]["product"]["width"]["unit"]) ? $productInfo["shipping_information"]["product"]["width"]["unit"] : "",
  1459.                     );
  1460.                     $updateProductArr["valid_up_to"] = $productBasicInfo["valid_up_to"];
  1461.                     $updateProductArr["special_price_valid_up_to"] = $productBasicInfo["special_price_valid_up_to"];
  1462.                     $updateProductArr["currency_array"] = array(
  1463.                         $default_country => 3
  1464.                     );
  1465.                     $updateProductArr["old_name"] = $productBasicInfo["title"];
  1466.                     $updateProductArr["global_pricing_keys"] = trim($globalPricingKeys',');
  1467.                     
  1468.                     $updateProductArr['project_id'] = $projectSetting['project_id'];
  1469.                     $updateProductArr['locale_language'] = $locale_language;
  1470.                     $updateProductArr['instance_type'] = $projectSetting['instance_type'];
  1471.                     $updateProductArr['instance_id'] = $projectSetting['instance_id'];
  1472.                     $updateProductArr['thumb_width'] =  $this->serviceContainer->getParameter('thumb_width');
  1473.                     $updateProductArr['medium_thumb_width'] = $this->serviceContainer->getParameter('medium_thumb_width');
  1474.                     //                             echo "<pre>";print_r($updateProductArr);exit;
  1475.                     return $updateProductArr;
  1476.     }
  1477.     public function callTioryPriceApiFromSku($sku$pricingYear)
  1478.     {
  1479.         $ch curl_init();
  1480.         
  1481. //         $sku = str_replace("-","",$sku);
  1482. //         $sku = ltrim($sku , "0");
  1483.         $postData = array("pricing_year"=>$pricingYear);
  1484.         $url "https://arc1967.tiory.com/api/update-tiory-price/$sku?pricing_year=".$pricingYear;
  1485.         //         $url = "https://arc1967.tiory.com/api/en_us/product/update-tiory-price?item_code=71117";
  1486.         curl_setopt($chCURLOPT_URL$url);
  1487.         curl_setopt($chCURLOPT_CUSTOMREQUEST'POST');
  1488.         curl_setopt($chCURLOPT_HTTPAUTHCURLAUTH_BASIC);
  1489.         curl_setopt($chCURLOPT_USERPWD"officebeacon:test123");
  1490.         curl_setopt($chCURLOPT_POSTFIELDSjson_encode($postData));
  1491.         curl_setopt($chCURLOPT_RETURNTRANSFER1);
  1492.         curl_setopt($chCURLOPT_TIMEOUT4);
  1493.         curl_setopt($chCURLOPT_TIMEOUT1000);
  1494.         curl_setopt($chCURLOPT_SSL_VERIFYPEER,false);
  1495.         $xml curl_exec($ch);
  1496.         return json_decode($xml,true);
  1497.         
  1498.     }
  1499.     
  1500.     /**
  1501.      *
  1502.      * Desciption: Order Sample
  1503.      *
  1504.      * @return json Response
  1505.      *
  1506.      * @Route("/product-order-sample",
  1507.      *     name="officebrain_product_bundle_product_order_sample"
  1508.      * )
  1509.      *
  1510.      * @Template("OfficeBrain/Bundle/ProductBundle/Product/productOrderSample.html.twig")
  1511.      */
  1512.     public function productOrderSampleAction(Request $request)
  1513.     {
  1514.         $this->initAction($request);
  1515.         $itemNo $this->request->get("itemno");
  1516.         $prodctid $this->request->get("prodctid");
  1517.         $this->responseArray['productSku'] = $itemNo;
  1518.         
  1519.         return $this->responseArray;
  1520.     }
  1521.     
  1522. }