src/OfficeBrain/Bundle/ProductBundle/Controller/ProductConfigureController.php line 405

Open in your IDE?
  1. <?php
  2. namespace App\OfficeBrain\Bundle\ProductBundle\Controller;
  3. // use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Translation\Translator;
  11. use App\OfficeBrain\Bundle\CoreBundle\CustomeHandler as FormErrorManager;
  12. use App\OfficeBrain\Bundle\CoreBundle\Cache\RedisCacheService;
  13. use App\OfficeBrain\Bundle\ProductTagBundle\Entity\ImprintProductMapping;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\DependencyInjection\ContainerInterface;
  16. use App\OfficeBrain\Bundle\ProductBundle\Manager\Service\ProductAdminManager;
  17. use App\OfficeBrain\Bundle\UserBundle\Manager\Service\UserService;
  18. use App\OfficeBrain\Bundle\ProductBundle\Manager\Service\ProductDetailService;
  19. use App\OfficeBrain\Bundle\ProductBundle\Manager\Service\BrandApiManager;
  20. use App\OfficeBrain\Bundle\ProductTagBundle\Manager\Service\ProductTagManager;
  21. use App\OfficeBrain\Bundle\SolrBundle\Manager\Service\SolrService;
  22. use App\OfficeBrain\Bundle\QueueBundle\Manager\Service\ApiManager as QueueApiManager;
  23. use App\OfficeBrain\Bundle\CategoryBundle\Manager\ApiManager as CategoryApiManager;
  24. /*
  25.  * This class for base functionality related to product admin. @author Office Brain - 4808 <support@officebrain.com>
  26.  */
  27. /**
  28.  * @Route("/admin/{_locale}/product")
  29.  */
  30. class ProductConfigureController extends AbstractController
  31. {
  32.     public function __construct(ContainerInterface $containerProductAdminManager $productAdminManagerUserService $userServiceProductDetailService $productDetailServiceBrandApiManager $brandApiManagerProductTagManager $productTagManagerSolrService $solrServiceQueueApiManager $queueApiManager)
  33.     {
  34.         $this->serviceContainer $container;
  35.         $this->productApiManager $productAdminManager;
  36.         $this->userService $userService->getUserExtended();
  37.         $this->productDetailManager $productDetailService->getProductApiExtended();
  38.         $this->brandApiManager $brandApiManager;
  39.         $this->productTagManager $productTagManager->getProductTagManagerExtended();
  40.         $this->solrService $solrService->getSolrServiceExtended();
  41.         $this->queueApiManager $queueApiManager->getQueueInstance();
  42.     }
  43.     CONST PRODUCT_CACHE_CLIENT 'product';
  44.     
  45.    /**
  46.      * @author Employee Id: 4808
  47.      * 
  48.      * Description : This function used for Set and intilize variables and request array
  49.      *
  50.      **/
  51.     public function init(Request $request){
  52.          $this->request $request;
  53.         $this->entityManager $this->getDoctrine()->getManager();
  54.         $this->session $this->request->getSession();
  55.         $this->translator $this->serviceContainer->get('translator');
  56.         $this->formErrorManager = new FormErrorManager\JsonError();
  57.         // $this->productApiManager = $this->serviceContainer->get("office_brain_product_admin_manager");
  58.         $this->productApiManager $this->productApiManager;
  59.         // $this->brandApiManager = $this->serviceContainer->get("officebrain_brand_api_manager");
  60.         $this->brandApiManager $this->brandApiManager;
  61.         $this->categoryApiManager $this->serviceContainer->get("officebrain_category_api_manager");
  62.         // $this->userManager = $this->serviceContainer->get("office_brain_user_manager");
  63.         $this->userManager $this->userService;
  64.         $this->projectSetting $this->request->get('project_setting');
  65.         $this->projectUserSetting $this->request->get('project_user_setting');
  66.         $this->userId $this->projectUserSetting['user_data'] ? $this->projectUserSetting['user_data']->getId() : 0;
  67.         // $this->productDetailManager = $this->serviceContainer->get('office_brain_product_detail_manager');
  68.         $this->productDetailManager $this->productDetailManager;
  69.         $this->productTagManager $this->productTagManager;
  70.         
  71.         $this->user $this->projectUserSetting['user_data'];
  72.         if (!$this->getUser() && $this->request->isXmlHttpRequest()) {
  73.            // throw new AccessDeniedHttpException();
  74.         }
  75.         // if ($this->serviceContainer->has('office_brain_queue_api_manager')) {
  76.         //     $this->request->attributes->set('object', 'Product');
  77.         //     $this->queueApiManager = $this->serviceContainer->get('office_brain_queue_api_manager');
  78.         // }
  79.         if ($this->queueApiManager) {
  80.             $this->request->attributes->set('object''Product');
  81.             $this->queueApiManager $this->queueApiManager;
  82.         }
  83.         
  84.         $this->statsh_cache_wrapper RedisCacheService::create();
  85.         $this->moduleCachePrefix='__RelatedProducts__';
  86.     }
  87.     
  88.     /**
  89.      * @author Employee Id: 4808
  90.      *
  91.      * Description : This function used for List Product Information
  92.      *
  93.      * @Route("/list/{page}",
  94.      * name="officebrain_bundle_product_list_product_wo_culture",
  95.      * requirements={"records_per_page"="12|24|48|100|996", "page"="\d+"},
  96.      * defaults={"records_per_page"=100,"page"=1})
  97.      *
  98.      * @Route("/list/{country}/{language}/{page}",
  99.      * name="officebrain_bundle_product_list_product",
  100.      * requirements={"records_per_page"="12|24|48|100|996","page"="\d+"},
  101.      * defaults={"records_per_page"=20,"page"=1})
  102.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/list.html.twig")
  103.      */
  104.     public function listProductAction(Request $request){
  105.         $this->init($request);
  106.         $projectSetting $this->request->get('project_setting');
  107.         list($defaultCulture,$defaultCountry) = explode("_",$this->request->get("_locale"));
  108.     
  109.         $param $this->request->get('_route_params');
  110.         $culture $this->request->get('language',$defaultCulture);
  111.         $country $this->request->get('country',$defaultCountry);
  112.         $activeCulture $culture;
  113.         $searchStatus $this->request->query->get('search_status''');
  114.         $searchQuery $this->request->query->get('search_query''');
  115.         $sortBy $this->request->query->get('sort''updatedAt');
  116.         $sortType $this->request->query->get('direction''desc');
  117.         $searchParam $this->request->query->get('search_param''');
  118.         $supplier_id $this->request->query->get('supplier_id','');
  119.         $brandIds $this->request->query->get('brand_id','');
  120.         $catIds $this->request->query->get('cat_id','');
  121.         $instanceType $projectSetting['instance_type'];
  122.         $cultureCategory =  $activeCulture "_" $country;
  123.     
  124.         // For Pagination
  125.         $page $this->request->get('page''1');
  126.         $records_per_page $param['records_per_page'];
  127.         $recordsPerPage $this->request->query->get('recordsPerPage',$records_per_page);
  128.         $start_index = (($page 1) * $recordsPerPage 1);
  129.         // End Pagination
  130.         $projectSetting $this->request->get('project_setting');
  131.     
  132.         $projectId $projectSetting['project_id'];
  133.         $productData $this->productApiManager->listProduct($searchStatus,$searchParam$searchQuery$sortType$sortBy,$activeCulture,$country,$supplier_id,$records_per_page,$page,$projectId,$brandIds,$catIds);
  134.         $supplierData $this->productApiManager->getSupplierNameList($projectId);
  135.         $brandData $this->brandApiManager->getList($culture);
  136.         //GET CATEGORY AND SUBCATEGORY
  137.         $categoryAndSubCategoryData $this->categoryApiManager->getList(array($cultureCategory),array(),true);
  138.         $this->catArrayNew = array();
  139.         if ($categoryAndSubCategoryData) {
  140.             foreach($categoryAndSubCategoryData[$cultureCategory] as $catKey=>$categoryAndSubCategory){
  141.                 $this->recursiveCategory($categoryAndSubCategory);
  142.             }
  143.             // Sort Category array using category name
  144.             usort($this->catArrayNew, function ($a$b) {
  145.                 return strcasecmp($a['cat_name'], $b['cat_name']);
  146.             });
  147.         }
  148.         $data['category_SubCategory_data'] = $this->catArrayNew;
  149.         $paginator  $this->serviceContainer->get('knp_paginator');
  150.         $data['pagination'] = $paginator->paginate($productData$page$recordsPerPage);
  151.         $data['page']=$page;
  152.         $data['search_status']=$searchStatus;
  153.         $data['search_query']=$searchQuery;
  154.         $data['sort_by']=$sortBy;
  155.         $data['sort_type']=$sortType;
  156.         $data['search_param']=$searchParam;
  157.         $data['supplier_id']=$supplier_id;
  158.         $data['records_per_page'] = $recordsPerPage;
  159.         $data['supplier_data'] = $supplierData;
  160.         $data['brand_id']=$brandIds;
  161.         $data['cat_id']=$catIds;
  162.         $data['brand_data']= $brandData[$culture];
  163.     
  164.         if(array_key_exists('status',$productData) && $productData['status'] == 'error' && is_array($productData))
  165.         {
  166.             $productSentData = array();
  167.             $data['error_message'] = $productData['error_message'];
  168.         }
  169.         else
  170.         {
  171.             if($productData['data']){
  172.                 $data['total_product'] = $productData['count'];
  173.                 $data['image_url'] = (array_key_exists('image_url',$productData)?$productData['image_url']:'');
  174.                 $productSentData $productData['data'];
  175.             }else{
  176.                 $productSentData = array();
  177.                 $data['error_message'] = $this->serviceContainer->get('translator')->trans("product.RECORD_NOT_FOUND");
  178.             }
  179.         }
  180.     
  181.         $data['params_to_append'] = array_merge($this->request->get('_route_params'), $this->request->query->all());
  182.     
  183.         return array('data'=>$data,'activeCountry' => $country'activeCulture'=>$activeCulture,'productData'=>$productSentData);
  184.     }
  185.     
  186.     
  187.     /**
  188.      * @author Employee Id: 5406
  189.      * 
  190.      * Description : This function used for List Product Information
  191.      * 
  192.      * @Route("/list-product-filtered-by-category/{productId}/{page}",
  193.      * name="officebrain_bundle_product_list_product_filtered_by_category_wo_culture",
  194.      * requirements={"records_per_page"="12|24|48|100|996", "page"="\d+"},
  195.      * defaults={"records_per_page"=20,"page"=1})
  196.      *
  197.      * @Route("/list-product-filtered-by-category/{productId}/{country}/{language}/{page}",
  198.      * name="officebrain_bundle_product_list_product_filtered_by_category",
  199.      * requirements={"records_per_page"="12|24|48|100|996","page"="\d+"},
  200.      * defaults={"records_per_page"=20,"page"=1})
  201.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/listProductFilteredByCategory.html.twig")
  202.      */
  203.     public function listProductFilteredByCategoryAction(Request $request$productId){
  204.         $this->init($request);
  205.         
  206.         list($defaultCulture,$defaultCountry) = explode("_",$this->request->get("_locale"));
  207.         
  208.         $param $this->request->get('_route_params');
  209.         $culture $this->request->get('language',$defaultCulture);
  210.         $country $this->request->get('country',$defaultCountry);
  211.         $countryId $this->serviceContainer->getParameter('country')[$country]['id'];
  212.         //echo $countryId= $this->country_;exit;
  213.         $activeCulture $culture;
  214.         $searchStatus $this->request->query->get('search_status''');
  215.         $searchQuery $this->request->query->get('search_query''');
  216.         $sortBy $this->request->query->get('sort''updatedAt');
  217.         $sortType $this->request->query->get('direction''desc');
  218.         $searchParam $this->request->query->get('search_param''');
  219.         $supplier_id $this->request->query->get('supplier_id','');
  220.         $brandIds $this->request->query->get('brand_id','');
  221.         $catIds $this->request->query->get('cat_id','');
  222.         
  223.         $cultureCategory =  $activeCulture "_" $country;
  224.         
  225. //      select all of the category ids from categorymapping entity, where product id of entity matches the product id passed in request, and country id of entity matches the country id passed in request
  226. //        then using those category ids we will filter out the products and then we will show only the products coming in these specific categories
  227.         $productCategoryIds $this->productApiManager->getCategoryIds($productId,$countryId);
  228.         $catIds implode(",",$productCategoryIds);
  229.         //print_r($productCategoryIds);exit;
  230.         $comproductreletedid =   $this->productApiManager->productreletedid($productId);
  231.         $productdetails $this->productDetailManager->getProductDetailById($productId,$cultureCategory);
  232.         $product_title $productdetails[$productId]['basic_information']['title'];
  233.         // For Pagination
  234.         $page $this->request->get('page''1');
  235.         $records_per_page $param['records_per_page'];
  236.         $recordsPerPage $this->request->query->get('recordsPerPage',$records_per_page);
  237.         $start_index = (($page 1) * $recordsPerPage 1);
  238.         // End Pagination
  239.         $projectSetting $this->request->get('project_setting');
  240.         
  241.         $projectId $projectSetting['project_id'];
  242.         $instanceType $projectSetting['instance_type'];
  243.         $productData $this->productApiManager->listProduct($searchStatus,$searchParam$searchQuery$sortType$sortBy,$activeCulture,$country,$supplier_id,$records_per_page,$page,$projectId,$brandIds,$catIds);
  244.         
  245.         /* code for not showing the parent product in related products started */
  246.         if(isset($productData['data']))
  247.         {
  248.             $productIndex 0;  
  249.             foreach($productData['data'] as $singleProductDetail)
  250.             {
  251.                 if(isset($singleProductDetail['product_master_id']))
  252.                 {
  253.                     if($singleProductDetail['product_master_id'] == $productId)
  254.                     { 
  255.                         unset($productData['data'][$productIndex]);
  256.                         //$productData['count'] = $productData['count'] - 1;
  257.                     }
  258.                 }
  259.                 $productIndex++;
  260.             }    
  261.         }
  262.         /* code for not showing the parent product in related products ended */
  263.         
  264.         $supplierData $this->productApiManager->getSupplierNameList($projectId);
  265.         $brandData $this->brandApiManager->getList($culture);
  266.         //GET CATEGORY AND SUBCATEGORY
  267.         $categoryAndSubCategoryData $this->categoryApiManager->getList(array($cultureCategory),array(),true);
  268.         $this->catArrayNew = array();
  269.         if ($categoryAndSubCategoryData) {
  270.             foreach($categoryAndSubCategoryData[$cultureCategory] as $catKey=>$categoryAndSubCategory){
  271.                 $this->recursiveCategory($categoryAndSubCategory);
  272.             }
  273.             // Sort Category array using category name
  274.             usort($this->catArrayNew, function ($a$b) {
  275.                 return strcasecmp($a['cat_name'], $b['cat_name']);
  276.             });
  277.         }
  278.         $data['category_SubCategory_data'] = $this->catArrayNew;
  279.         $paginator  $this->serviceContainer->get('knp_paginator');
  280.         $data['pagination'] = $paginator->paginate($productData$page$recordsPerPage);
  281.         $data['page']=$page;
  282.         $data['search_status']=$searchStatus;
  283.         $data['search_query']=$searchQuery;
  284.         $data['sort_by']=$sortBy;
  285.         $data['sort_type']=$sortType;
  286.         $data['search_param']=$searchParam;
  287.         $data['supplier_id']=$supplier_id;
  288.         $data['records_per_page'] = $recordsPerPage;
  289.         $data['supplier_data'] = $supplierData;
  290.         $data['brand_id']=$brandIds;
  291.         $data['cat_id']=$catIds;
  292.         $data['brand_data']= $brandData[$culture];
  293.         $data['INSTANCE_TYPE'] = $instanceType;
  294.         
  295.         if(array_key_exists('status',$productData) && $productData['status'] == 'error' && is_array($productData))
  296.         {
  297.             $productSentData = array();
  298.             $data['error_message'] = $productData['error_message'];
  299.         }
  300.         else
  301.         {
  302.             if($productData['data']){
  303.                 $data['total_product'] = $productData['count'];
  304.                 $data['image_url'] = (array_key_exists('image_url',$productData)?$productData['image_url']:'');
  305.                 $productSentData $productData['data'];
  306.             }else{
  307.                 $productSentData = array();
  308.                 $data['error_message'] = $this->serviceContainer->get('translator')->trans("product.RECORD_NOT_FOUND");
  309.             }
  310.         }
  311.         
  312.         $data['params_to_append'] = array_merge($this->request->get('_route_params'), $this->request->query->all());
  313.         return array('data'=>$data,'activeCountry' => $country'activeCulture'=>$activeCulture,'productData'=>$productSentData,'productId' => $productId,'comproductreletedid'=> $comproductreletedid,'product_title'=>$product_title);
  314.     }
  315.     
  316.     
  317.     /**
  318.      * EMp Id : 4246
  319.      * Description : This Function is Used For Update Product Status According To Parameter
  320.      *
  321.      * @Route("/change-relation-status/{country}/{set_status}",
  322.      * requirements = {"set_status"="1|0"},
  323.      * name="officebrain_product_change_relation_status")
  324.      */
  325.     public function changeProductRelationStatusAction(Request $request){
  326.         $this->init($request);
  327.         $param=$this->request->get('_route_params');
  328.         $productId=$this->request->get('productId');
  329.         $setStatus=$this->request->get('set_status');
  330.          
  331.         $relatedProductIds = array();
  332.         $relatedProductIds $this->request->get('ids','');
  333.         $relatedProductIds explode("::",$relatedProductIds);
  334.     
  335.         $projectSetting $this->request->get('project_setting');
  336.         $locale_language $projectSetting['locale_language'];
  337.     
  338.         //$productAdminManager = $this->get('office_brain_product_admin_manager');
  339.          
  340.         if($setStatus == 1)
  341.         {
  342.             $productData $this->productApiManager->insertRelatedProducts($productId,$relatedProductIds,$locale_language);
  343.         }
  344.         else if($setStatus == 0)
  345.         {
  346.             $productData $this->productApiManager->deleteRelatedProducts($productId,$relatedProductIds,$locale_language);
  347.         }
  348.     
  349.         $data = array();
  350.         $data['status'] = 'success';
  351.         $data['message'] = $this->translator->trans('product.PRODUCT_RELATION_UPDATED');
  352.         
  353.         RedisCacheService::removeCacheByPrefix($this->statsh_cache_wrapper,$this->moduleCachePrefix);
  354.         
  355.         return new JsonResponse($data);
  356.     }
  357.     
  358.     
  359.     /**
  360.      * Recursive function for category list
  361.      * 
  362.      * @param array $catArray
  363.      */
  364.     public function recursiveCategory($catArray){
  365.         if (array_key_exists("child",$catArray)) {
  366.             foreach($catArray['child'] as $subCatArray){
  367.                 if (array_key_exists("child",$subCatArray)) {
  368.                    foreach ($subCatArray['child'] as $leafCat) {
  369.                        $this->recursiveCategory($leafCat);
  370.                    }
  371.                 }
  372.                 else{
  373.                     $this->catArrayNew[] = $subCatArray;
  374.                 }
  375.             }
  376.         } 
  377.         else {
  378.               $this->catArrayNew[] = $catArray;
  379.         }
  380.     }
  381.     public function deleteCache($productId=0,$culture)
  382.     {
  383.         
  384.         if(!RedisCacheService::isCacheEnable())
  385.         {
  386.             return null;
  387.         }
  388.         $cacheClient=RedisCacheService::create(null,self::PRODUCT_CACHE_CLIENT);
  389.         //echo "===========$productId.':*'.$culture==========";
  390.         
  391.         // $cacheClient->removeCacheByPrefix($productId.':*'.$culture);
  392.     }
  393.     /**
  394.      * @author Employee Id: 4808
  395.      * 
  396.      * Description : This function used for Add Product Information 
  397.      * @return array 
  398.      * @Route("/add", name="officebrain_product_add"),
  399.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/add.html.twig")
  400.      */
  401.     public function addAction(Request $request){
  402.         $this->init($request);
  403.         $projectSetting $this->request->get('project_setting');             
  404.         $instanceType $projectSetting['instance_type'];
  405.         
  406.         $cultureName $this->request->get('culture_name');
  407.         $master_product_id $this->request->get('master_product_id''');
  408.         $param $this->request->get('_route_params');
  409.         $route $this->request->get('_route');
  410.         
  411.         $locale_language $param['_locale'];
  412.         $productAddSettings $projectSetting['configuration_rule']['product']['add_update'];
  413.         $supplier_id 0;
  414.         // set global_pricing_keys which are active
  415.         $globalPricingKeys '';        
  416.         if(array_key_exists('global_pricing'$productAddSettings))
  417.         {
  418.             foreach ($productAddSettings['global_pricing'] as $key => $val
  419.             {
  420.                 if ($val['status'] == 1
  421.                 {
  422.                     $globalPricingKeys .= ($val['pricing_box_id'].':'.$val['pricing_box_name']).',';
  423.                 }
  424.             }
  425.         }
  426.         
  427.         //$supplierData = $this->productApiManager->getSupplierNameList($projectSetting['project_id']);        
  428.         
  429.         if ($this->request->isXmlHttpRequest() && $this->request->getMethod()=='POST') {
  430.             $data $this->request->request->all();
  431.             $data['valid_up_to']=str_replace('/','-',$data['valid_up_to']);
  432.             $data['special_price_valid_up_to']=str_replace('/','-',$data['special_price_valid_up_to']);
  433.             $data['pricing_valid_until']=str_replace('/','-',$data['pricing_valid_until']);
  434.             $data['pricing_valid_starting']=str_replace('/','-',$data['pricing_valid_starting']);
  435.             $data['master_product_id'] = $master_product_id;
  436.             $data['project_id'] = $projectSetting['project_id'];
  437.             $data['locale_language'] = $locale_language;
  438.             $data['instance_type'] = $projectSetting['instance_type'];
  439.             $data['instance_id'] = $projectSetting['instance_id'];
  440.             $data['thumb_width'] =  $this->serviceContainer->getParameter('thumb_width');
  441.             $data['medium_thumb_width'] = $this->serviceContainer->getParameter('medium_thumb_width');
  442.   
  443.             $apiResponse =  $this->productApiManager->add($cultureName$data);
  444.             if ($apiResponse['status']=='success') {
  445.                 $response = array('form_status' => $apiResponse['status'],'success_message'=>$this->serviceContainer->get('translator')->trans($apiResponse['success_message']));
  446.                 $this->session->set('product-list-success'$this->serviceContainer->get('translator')->trans($apiResponse['success_message']));
  447.                 
  448.                 $actionPerformed 'create';
  449.                 if ($master_product_id) { 
  450.                     $actionPerformed 'update';
  451.                     /* Remove Cache Of Product Details Page */
  452.                     $statsh_cache_wrapper RedisCacheService::create();
  453.                     $moduleCachePrefix '__ProductDetailsPageOtherProducts';
  454.                     RedisCacheService::removeCacheByPrefix($statsh_cache_wrapper,$moduleCachePrefix."*product_id#".$master_product_id);
  455.                     /* EO: Remove Cache Of Product Details Page */
  456.                 }
  457.                 if($data['product_name']['en']!=$data['old_name']){
  458.                     $this->deleteCache($apiResponse['master_product_id'],'en_us');
  459.                 }
  460.                 
  461.                 //SOLR SYNC CODE START
  462.                 $is_solr_syn_enabled $this->serviceContainer->getParameter('solr_sync');
  463.                 if($is_solr_syn_enabled){
  464.                     $env $this->serviceContainer->getParameter("kernel.environment");
  465.                     $localization_to_update $this->serviceContainer->getParameter('localization_to_fetch');
  466.                     // $this->productApiManager->updateSolrData($apiResponse['master_product_id'],$localization_to_update,$projectSetting['project_id'],$env,'update'); // symfony 4
  467.                     $this->productApiManager->updateSolrData($apiResponse['master_product_id'],$localization_to_update,$projectSetting['project_id'],$env,$projectSetting['instance_id'],'update');
  468.                 }
  469.                 
  470.                 //SOLR SYNC CODE END
  471.                 
  472.                 // To Integrate With ERP
  473.                 $erpIntegration $projectSetting['configuration_rule']['erp_integration'];
  474.                 if($erpIntegration && $erpIntegration['productManagement'] == && !empty($this->queueApiManager)) {
  475.                     $this->productApiManager->integrateWithErp($this->queueApiManager$actionPerformed$apiResponse['master_product_id']);
  476.                 }
  477.                 if($this->request->get('syncflag')==1){ 
  478.                     if($productAddSettings['asi_call']['status']){
  479.                         foreach ($apiResponse['product_slugs'] as $culture => $slug){
  480.                             if($master_product_id 0)
  481.                             {
  482.                                 $this->productDetailManager->updateSyncDetail($this->request->get('syncflag'),$data['sku']);
  483.                                 $asiurl 'http://demoapi.officebrain.com/update_product_api.php?product_slug='.$slug;
  484.                             }
  485.                             else
  486.                             {
  487.                                 $this->productDetailManager->insertSyncDetail($this->request->get('syncflag'),$data['sku']);
  488.                                 $asiurl 'http://demoapi.officebrain.com/product_api.php?product_slug='.$slug;
  489.                             }
  490.                             //echo $asiurl;die;
  491.                             exec("curl '$asiurl' > /dev/null &");
  492.                         }
  493.                     }
  494.                 }
  495.                 else
  496.                 {
  497.                     if($master_product_id 0)
  498.                     {
  499.                         $this->productDetailManager->updateSyncDetail(0,$data['sku']);
  500.                     }
  501.                     else
  502.                     {
  503.                         $this->productDetailManager->insertSyncDetail(0,$data['sku']);
  504.                     }
  505.                     if(isset($data['sku']) && !empty($data['sku'])){
  506.                         $asiurl 'http://demoapi.officebrain.com/product_delete_api.php?product_sku='.$data['sku'];
  507.                         exec("curl '$asiurl' > /dev/null &");
  508.                     }
  509.                 }
  510.                 
  511.             } else {
  512.                 $response = array('form_status' => $apiResponse['status'],'error_message'=>$this->serviceContainer->get('translator')->trans($apiResponse['message']));
  513.             }
  514.             return new JsonResponse($response);
  515.         }
  516.         $data_to_set =  $this->productApiManager->preSetDataForPlugin($projectSetting['configuration_rule']['product'],$projectSetting['project_id'],'',1);
  517.         $this->viewTwigData['plugin_data'] = $data_to_set['plugin_data'];
  518.         $this->viewTwigData['ATTR_TYPE_IDS'] = $this->serviceContainer->getParameter('attributes_types');
  519.         $this->viewTwigData['ATTR_IMPRINT_POSITION'] = $this->serviceContainer->getParameter('imprint_position_master_id');
  520.         $this->viewTwigData['ATTR_COLOR_ID'] = $this->serviceContainer->getParameter('color_attribute_id');        
  521.         $this->viewTwigData['params_to_append'] = array_merge($this->request->get('_route_params'), $this->request->query->all());
  522.         $this->viewTwigData['form_method'] = 'add';
  523.         $this->viewTwigData['global_pricing_keys'] = trim($globalPricingKeys',');
  524.         $this->viewTwigData['INSTANCE_TYPE'] = strtolower($instanceType);
  525.         return $this->viewTwigData;
  526.     }
  527.     
  528.     /**
  529.      * @author Employee Id: 4045
  530.      *
  531.      * Description : This function used to Edit Product Information
  532.      * @return array
  533.      * @Route("/edit/{master_product_id}", name="officebrain_product_edit"),
  534.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/add.html.twig")
  535.      */
  536.     public function editNewAction(Request $request){
  537.         $this->init($request);
  538.         $projectSetting $this->request->get('project_setting');
  539.         $countryArray $this->serviceContainer->getParameter('country');
  540.         $languageArray $this->serviceContainer->getParameter('language');
  541.         $country_to_pass array_column($countryArray,'short_name');
  542.         $language_to_pass array_keys($languageArray);
  543.         $locale $this->request->get('_locale',$this->serviceContainer->getParameter('locale'));
  544.         @list($default_language,$default_country) = explode("_",$locale);
  545.         $cultureName $this->request->get('culture_name');
  546.         $masterProductId $this->request->get('master_product_id''');
  547.         $param $this->request->get('_route_params');
  548.         $route $this->request->get('_route');
  549.         $quoteId $this->request->get('quote_id',0);
  550.         
  551.         // set global_pricing_keys which are active
  552.         $globalPricingKeys '';
  553.         $productAddSettings $projectSetting['configuration_rule']['product']['add_update'];
  554.         if(array_key_exists('global_pricing'$productAddSettings))
  555.         {
  556.             foreach ($productAddSettings['global_pricing'] as $key => $val)
  557.             {
  558.                 if ($val['status'] == 1)
  559.                 {
  560.                     $globalPricingKeys .= ($val['pricing_box_id'].':'.$val['pricing_box_name']).',';
  561.                 }
  562.             }
  563.         }
  564.         $productInfo $this->productApiManager->editView($masterProductId,$language_to_pass,$country_to_pass,$default_language);
  565.         $syncentityobj$this->productDetailManager->getSyncDetail($productInfo['en']['basic_information']['sku_number']);
  566.        //$supplierData = $this->productApiManager->getSupplierNameList($projectSetting['project_id']);
  567.         if(isset($syncentityobj))
  568.         {
  569.             $productInfo['syncflag']=$syncentityobj['isSync'];
  570.         }
  571.         else
  572.         {
  573.             $productInfo['syncflag']=0;
  574.         }
  575.         if(!count($productInfo)){
  576.             throw $this->createNotFoundException('The product does not exist');
  577.         }
  578.         
  579.         $data_to_set =  $this->productApiManager->preSetDataForPlugin($projectSetting['configuration_rule']['product'], $projectSetting['project_id'],$productInfo);
  580.         $this->viewTwigData['plugin_data'] = $data_to_set['plugin_data'];
  581.         $this->viewTwigData['ATTR_TYPE_IDS'] = $this->serviceContainer->getParameter('attributes_types');
  582.         $this->viewTwigData['ATTR_IMPRINT_POSITION'] = $this->serviceContainer->getParameter('imprint_position_master_id');
  583.         $this->viewTwigData['ATTR_COLOR_ID'] = $this->serviceContainer->getParameter('color_attribute_id');
  584.         $this->viewTwigData['params_to_append'] = array_merge($this->request->get('_route_params'), $this->request->query->all());
  585.         $this->viewTwigData['master_product_id'] = $masterProductId;
  586.         $this->viewTwigData['form_method'] = 'edit';
  587.         $this->viewTwigData['global_pricing_keys'] = trim($globalPricingKeys',');
  588.         return $this->viewTwigData;
  589.     }
  590.     /**
  591.      * @author: Employee Id : 4808
  592.      * Description: This Function is Related For Image Library
  593.      *
  594.      * @Route("/image-library",name="officebrain_product_image_library"),
  595.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/imageLibrary.html.twig")
  596.      */
  597.     public function imageLibraryAction(Request $request){
  598.         //TODO: need to get dynamic product once listing get done
  599.        $this->init($request);
  600.        $this->viewTwigData['data']=array('productId'=>1);
  601.         $mainErrorMessage='';
  602.         $isImageUploaded false;
  603.         if ($this->request->getMethod() == "POST" ) {
  604.             $request $request;
  605.             $fileData $request->files->get("FileUpload");
  606.             $zipData $request->files->get("zipUpload");
  607.             $fileUploadType $request->get('FileUpload_type');
  608.             //TODO: need to get dynamic product once listing get done
  609.             $productId 1;
  610.             $index 0;
  611.             $imageArray = array();
  612.             foreach($fileData as $image){
  613.                 foreach($image as $v){
  614.                     if(!empty($v)){
  615.                         $isImageUploaded true;
  616.                         break;
  617.                     }
  618.                 }
  619.                 if($isImageUploaded) break;
  620.             }
  621.             if(!$isImageUploaded){
  622.                 foreach($zipData as $image){
  623.                     foreach($image as $v){
  624.                         if(!empty($v)){
  625.                             $isImageUploaded true;
  626.                             break;
  627.                         }
  628.                     }
  629.                     if($isImageUploaded) break;
  630.                 }
  631.             }
  632.             $mainErrorMessage='';
  633.             if(!$isImageUploaded){
  634.                 $mainErrorMessage =  $this->serviceContainer->get('translator')->trans('admin.image_template_library.select_files_error_msg');
  635.             }
  636.             $res =  $this->productApiManager->uploadfiles($productId$fileData,'image',$fileUploadType);
  637.             $error_file_upload $res['error_file_upload'];
  638.             $res $this->productApiManager->uploadfiles($productId$zipData,'zip');
  639.             $error_file_upload_zip $res['error_file_upload'];
  640.         }
  641.         $errMsg '';
  642.         $successMsg '';
  643.         if (!empty($error_file_upload) || !empty($error_file_upload_zip)) {
  644.             $errMsg '<ul>';
  645.             $arrImgType = array('web' => 'Web''template' => 'Template''high_res' => 'High Res');
  646.             foreach ($arrImgType as $type => $files) {
  647.                 if (isset($error_file_upload[$type]) || isset($error_file_upload_zip[$type])) {
  648.                     $errMsg.="<li>" $files "<ul>\n";
  649.                     if (isset($error_file_upload[$type])) {
  650.                         foreach ($error_file_upload[$type] as $fileName => $error) {
  651.                             $errMsg.="<li>" $fileName ":<i><b>" $error "</b></i></li>";
  652.                         }
  653.                     }
  654.                     if (isset($error_file_upload_zip[$type])) {
  655.                         foreach ($error_file_upload_zip[$type] as $fileName => $error) {
  656.                             $errMsg.="<li>" $fileName ":<i><b>" $error "</b></i></li>";
  657.                         }
  658.                     }
  659.                     $errMsg.="</ul></li>";
  660.                 }
  661.             }
  662.             $errMsg.='</ul>';
  663.         }elseif($mainErrorMessage != '' ){
  664.             $errMsg '<ul><li>'.$mainErrorMessage.'</li></ul>';
  665.         }elseif($isImageUploaded){
  666.             $successMsg $this->serviceContainer->get('translator')->trans('admin.image_template_library.upload_succ');
  667.         }
  668.        return $this->viewTwigData;
  669.     }
  670.     /**
  671.      * @Route("/browse-product-image", name="OfficeBrainImageLibraryAdmin_browse_product_image", methods={"POST"})
  672.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/browseProductImage.html.twig")
  673.      */
  674.     public function browseProductImageAction(Request $request) {
  675.         $this->init($request);
  676.         $this->request $request;
  677.         $productId intval($this->request->get('id'));
  678.         $imageType $this->request->get('type');
  679.         $data $this->productApiManager->productImages($productId,$imageType);
  680.         $imageArray = array();
  681.         if($data){
  682.             if($imageType =='high_res'){
  683.                 foreach($data as $image){
  684.                     
  685.                     if(trim($image['fileType'])!='imprinted')
  686.                         $imageArray['blank'][]=$image;
  687.                     else
  688.                         $imageArray['imprinted'][]=$image;
  689.                 }
  690.             } else {
  691.                 $imageArray $data;
  692.             }
  693.         }
  694.         return array('imageArray' => $imageArray'imageType' => $imageType);
  695.     }
  696.     /**
  697.      * @Route("/remove-product-image",
  698.      * name="officebrain_image_library_admin_bundle_remove_product_image", methods={"GET","POST"}),
  699.      * @Template()
  700.      */
  701.     public function removeProductImageAction(Request $request) {
  702.         $this->init($request);
  703.         $productId $this->request->get('productId');
  704.         $imageType $this->request->get('imageType');
  705.         $imageId $this->request->get('imageId');
  706.         
  707.         $result $this->productApiManager->removeProductImage($productId,$imageId);
  708.         if ($result)
  709.             echo $this->serviceContainer->get('translator')->trans('admin.image_template_library.image_removed_succ');
  710.         else
  711.             echo $this->serviceContainer->get('translator')->trans('admin.image_template_library.image_removed_fail');
  712.     }
  713.     /**
  714.      * @author Employee Id: 4246
  715.      * Description : This function used for View Product Information
  716.      * @Route("/view",
  717.      * name="officebrain_product_view")
  718.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/view.html.twig")
  719.      */
  720.     public function viewAction(Request $request){
  721.         $this->init($request);
  722.         $product_culture $this->request->get('product_culture');
  723.         $product_ids $this->request->get('product_ids');
  724.         //$productAdminManager = $this->get('office_brain_product_admin_manager');
  725.         $productData $this->productApiManager->view($product_ids,$product_culture,true);
  726.         
  727.         $projectSetting $this->request->get('project_setting');
  728.         $productAddSettings $projectSetting['configuration_rule']['product']['add_update'];
  729.         if(array_key_exists('global_pricing'$productAddSettings))
  730.         {
  731.             foreach ($productAddSettings['global_pricing'] as $key => $val)
  732.             {
  733.                 if ($val['status'] == 1)
  734.                 {
  735.                     $global_pricing_arr[$key] = 1;
  736.                 }
  737.             }
  738.         }
  739.         
  740.         $culture_id $this->request->get('culture_id');
  741.         if(!count($productData)){
  742.             throw $this->createNotFoundException('The product does not exist');
  743.         }
  744.         if($productData['status'] == "success"){
  745.             $productInfo $productData['data'];
  746.             if(array_key_exists('price_unit',$productInfo[$product_ids])){
  747.                 $priceUnit $this->serviceContainer->getParameter('price_unit');
  748.                 $productInfo[$product_ids]['price_unit'] = array_key_exists(trim($productInfo[$product_ids]['price_unit']),$priceUnit)?$priceUnit[$productInfo[$product_ids]['price_unit']]:$productInfo[$product_ids]['price_unit'];
  749.             }
  750.             $this->viewTwigData['data'] = $productInfo[$product_ids];
  751.         }else{
  752.             $this->viewTwigData['error_message'] = $this->serviceContainer->get('translator')->trans('product.'.$productData['message']);
  753.         }
  754.         $this->viewTwigData['params_to_append'] = array_merge($this->request->get('_route_params'), $this->request->query->all());
  755.         $this->viewTwigData['global_pricing_arr'] = $global_pricing_arr;
  756.         return $this->viewTwigData;
  757.     }
  758.     /**
  759.      * @author Employee Id: 4246
  760.      * Description : This function used for Delete Product
  761.      * @Route("/delete",
  762.      * name="officebrain_product_delete")
  763.      */
  764.     public function deleteAction(Request $request){
  765.         $this->init($request);
  766.         $product_master_id $this->request->get('product_master_id');
  767.         $product_country $this->request->get('product_country');
  768.         $projectSetting $this->request->get('project_setting');
  769.         $project_id $projectSetting['project_id'];
  770.         $locale_language $projectSetting['locale_language'];
  771.         $supplier_id $projectSetting['user_id'];
  772.         $instance_type $projectSetting['instance_type'];
  773.         $instance_id $projectSetting['instance_id'];
  774.         $productData $this->productApiManager->delete($product_master_id$project_id$supplier_id$locale_language$instance_type$instance_id$product_country);
  775.         // Data Array Convert Object To Array
  776.         $productData['data'] = (array)$productData['data'];
  777.         if($productData['status'] == 'success'){
  778.             $data['status'] = 'success_message';
  779.             //SOLR SYNC CODE START
  780.              $is_solr_syn_enabled $this->serviceContainer->getParameter('solr_sync');
  781.              if($is_solr_syn_enabled){
  782.                  $env $this->serviceContainer->getParameter("kernel.environment");
  783.                  $localization_to_update $this->serviceContainer->getParameter('localization_to_fetch');
  784.                  $this->productApiManager->updateSolrData($product_master_id,$localization_to_update,$projectSetting['project_id'],$env,'delete');
  785.              }
  786.             //SOLR SYNC CODE END
  787.                 
  788.             // To Integrate with ERP
  789.             $erpIntegration $projectSetting['configuration_rule']['erp_integration'];
  790.             if($erpIntegration && $erpIntegration['productManagement'] == && !empty($this->queueApiManager)) {
  791.                 $dt = new \DateTime($productData['data']['deleted_at']);
  792.                 $params = array('product_id' => $product_master_id'country_id' => $productData['data']['country_id'], 'deleted_at'=> $dt->format('Y-m-d H:i:s'));
  793.                 $this->productApiManager->integrateWithErp($this->queueApiManager'remove'$product_master_id$params);
  794.             }
  795.         }else{
  796.             $data['status'] = 'error_message';
  797.         }
  798.         $data['message'] = $this->translator->trans($productData['message']);
  799.         return new JsonResponse($data);
  800.     }
  801.     
  802.     /**
  803.      * EMp Id : 4246
  804.      * Description : This Function is Used For Update Product Status According To Parameter
  805.      * 
  806.      * @Route("/changestatus/{country}/{set_status}",
  807.      * requirements = {"set_status"="1|0"},
  808.      * name="officebrain_product_changestatus")
  809.      */
  810.     public function changeProductStatusAction(Request $request){
  811.         $this->init($request);
  812.         $param=$this->request->get('_route_params');
  813.         
  814.         $ids_to_pass = array();
  815.         $ids $this->request->get('ids','');
  816.         $ids_to_pass explode("::",$ids);
  817.         $productId json_encode($ids_to_pass);
  818.         
  819.         list($defaultCulture,$defaultCountry) = explode("_",$this->request->get("_locale"));
  820.         $projectSetting $this->request->get('project_setting');
  821.         $culture $this->request->get('language',$defaultCulture);
  822.         $country $this->request->get('country');
  823.         $setStatus $this->request->get('set_status');
  824.         $cultureCategory =  $culture"_" $country;
  825.         
  826.         $project_id $projectSetting['project_id'];
  827.         $locale_language $projectSetting['locale_language'];
  828.         $supplier_id $projectSetting['user_id'];
  829.         $instance_type $projectSetting['instance_type'];
  830.         $instance_id $projectSetting['instance_id'];
  831.         
  832.         //$productAdminManager = $this->get('office_brain_product_admin_manager');
  833.         $productData $this->productApiManager->changeProductStatus($productId,$country,$setStatus$project_id$supplier_id$locale_language$instance_type$instance_id);
  834.         $data = array();
  835.         if($productData['status'] == 'success'){            
  836.             //SOLR SYNC CODE START
  837.             $is_solr_syn_enabled $this->serviceContainer->getParameter('solr_sync');
  838.             if($is_solr_syn_enabled){
  839.                 $env $this->serviceContainer->getParameter("kernel.environment");
  840.                 $localization_to_update $this->serviceContainer->getParameter('localization_to_fetch');
  841.                 // $solrProductManager = $this->serviceContainer->get('office_brain_solr_product_mapping_manager');
  842.                 $solrProductManager $this->solrService;
  843.                 foreach($ids_to_pass as $product_id_to_process){
  844.                     if(!$setStatus){
  845.                         $this->productApiManager->updateSolrData($product_id_to_process,$localization_to_update,$projectSetting['project_id'],$env$instance_id,'delete');
  846.                         $productdetails $this->productDetailManager->getProductDetailById($product_id_to_process,$cultureCategory);
  847.                         
  848.                         if(strpos($productdetails[$product_id_to_process]['basic_information']['sku_number'], '-') != false && isset($productdetails[$product_id_to_process]['other_products'])){
  849.                             $main_sku $productdetails[$product_id_to_process]['basic_information']['sku_number'];
  850.                             $main_sku explode('-'$main_sku); // get main sku
  851.                             $mainSku $main_sku[1];                 
  852.                             if(isset($productdetails[$product_id_to_process]['other_products']) && is_array($productdetails[$product_id_to_process]['other_products'])){
  853.                                 $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 );
  854.                                 usort($productdetails[$product_id_to_process]['other_products'], function ($a$b) use ($sortOrder) {
  855.                                     $pos_a array_search($a['sku_number'], $sortOrder);
  856.                                     $pos_b array_search($b['sku_number'], $sortOrder);
  857.                                     return $pos_a $pos_b;
  858.                                 });
  859.                                 
  860.                             }
  861.                             else{
  862.                                 $productdetails[$product_id_to_process]['other_products'] = null;
  863.                             }
  864.                             // Update other Products
  865.                             if(isset($productdetails[$product_id_to_process]['other_products']) && !empty($productdetails[$product_id_to_process]['other_products'])){
  866.                                 foreach($productdetails[$product_id_to_process]['other_products'] as $otherProduct){
  867.                                     if( $otherProduct['id'] == $product_id_to_process ){
  868.                                         $this->productApiManager->updateSolrData($otherProduct['id'],$localization_to_update,$projectSetting['project_id'],$env$instance_id,'delete');
  869.                                     }
  870.                                     else{
  871.                                         $this->productApiManager->updateSolrData($otherProduct['id'],$localization_to_update,$projectSetting['project_id'],$env$instance_id,'update');
  872.                                     }
  873.                                 }
  874.                             }
  875.                         }
  876.                         // update main sku
  877.                         // if($productdetails[$product_id_to_process]['basic_information']['sku_number']){
  878.                         //     $sku_split = explode('-',$productdetails[$product_id_to_process]['basic_information']['sku_number']);
  879.                         //     if(count($sku_split) == 2){
  880.                         //         $productDetailArray =$this->productDetailManager->getProductDetailBySku($sku_split[1],$productdetails[$product_id_to_process]['supplier']['supplier_id'],$cultureCategory);
  881.                         //         $this->productApiManager->updateSolrData($productDetailArray['product_id'],$localization_to_update,$projectSetting['project_id'],$env,'update');
  882.                                 
  883.                         //     }
  884.                         // }
  885.                     }else{
  886.                         $this->productApiManager->updateSolrData($product_id_to_process,$localization_to_update,$projectSetting['project_id'],$env$instance_id,'update');
  887.                         $productdetails $this->productDetailManager->getProductDetailById($product_id_to_process,$cultureCategory);
  888.                         
  889.                         // Update other Products
  890.                         if(strpos($productdetails[$product_id_to_process]['basic_information']['sku_number'], '-') != false && isset($productdetails[$product_id_to_process]['other_products'])){
  891.                             $main_sku $productdetails[$product_id_to_process]['basic_information']['sku_number'];
  892.                             $main_sku explode('-'$main_sku); // get main sku
  893.                             $mainSku $main_sku[1];                 
  894.                             if(isset($productdetails[$product_id_to_process]['other_products']) && is_array($productdetails[$product_id_to_process]['other_products'])){
  895.                                 $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 );
  896.                                 usort($productdetails[$product_id_to_process]['other_products'], function ($a$b) use ($sortOrder) {
  897.                                     $pos_a array_search($a['sku_number'], $sortOrder);
  898.                                     $pos_b array_search($b['sku_number'], $sortOrder);
  899.                                     return $pos_a $pos_b;
  900.                                 });
  901.                                 
  902.                             }
  903.                             else{
  904.                                 $productdetails[$product_id_to_process]['other_products'] = null;
  905.                             }
  906.                         }
  907.                         if(isset($productdetails[$product_id_to_process]['other_products']) && !empty($productdetails[$product_id_to_process]['other_products'])){
  908.                             $index 1;
  909.                             $isFound 0;
  910.                             $operation 'update';
  911.                             foreach($productdetails[$product_id_to_process]['other_products'] as $otherProduct){
  912.                                 if($index == && $otherProduct['id'] == $product_id_to_process){
  913.                                     $isFound 1;
  914.                                     $operation 'update';
  915.                                 }
  916.                                 elseif( $index && $otherProduct['id'] == $product_id_to_process){
  917.                                     $isFound 1;
  918.                                     $operation 'delete';
  919.                                 }
  920.                                 elseif($isFound == 1){
  921.                                     $operation 'delete';
  922.                                 }
  923.                                 else{
  924.                                     $operation 'update';
  925.                                 }
  926.                                 $this->productApiManager->updateSolrData($otherProduct['id'],$localization_to_update,$projectSetting['project_id'],$env$instance_id,$operation);
  927.                                 if($operation == 'delete'){
  928.                                     $this->productApiManager->updateSolrData($otherProduct['id'],$localization_to_update,$projectSetting['project_id'],$env$instance_id,'update');
  929.                                 }
  930.                                 $index++;
  931.                             }
  932.                         }
  933.                         
  934.                         // if($productdetails[$product_id_to_process]['basic_information']['sku_number']){
  935.                         //     $sku_split = explode('-',$productdetails[$product_id_to_process]['basic_information']['sku_number']);
  936.                         //     if(count($sku_split) == 2){
  937.                         //         $productDetailArray =$this->productDetailManager->getProductDetailBySku($sku_split[1],$productdetails[$product_id_to_process]['supplier']['supplier_id'],$cultureCategory);
  938.                         //         $this->productApiManager->updateSolrData($productDetailArray['product_id'],$localization_to_update,$projectSetting['project_id'],$env,'update');
  939.                         //     }
  940.                         // }
  941.                     }
  942.                 }
  943.             }
  944.             //SOLR SYNC CODE END
  945.             
  946.             // To Integrate with ERP
  947.             $productIds json_decode($productId);
  948.             $erpIntegration $projectSetting['configuration_rule']['erp_integration'];
  949.             if($erpIntegration && $erpIntegration['productManagement'] == && !empty($this->queueApiManager)) {
  950.                 foreach ($productData['data'] as $key => $value) {
  951.                     $params = array('product_id' => $productIds[$key], 'country_id' => $value['countryId'],'status'=> $setStatus);
  952.                     $this->productApiManager->integrateWithErp($this->queueApiManager'updateStatus'$productIds[$key], $params);
  953.                 }
  954.             }
  955.             $data['status'] = 'success';
  956.             RedisCacheService::removeCacheByPrefix($this->statsh_cache_wrapper,$this->moduleCachePrefix);
  957.             
  958.         }else{
  959.             $data['status'] = 'error';
  960.         }
  961.         $data['message'] = $this->translator->trans('product.'.$productData['message']);
  962.         return new JsonResponse($data);
  963.     }
  964.     
  965.     /**
  966.      * EMp Id : 4246
  967.      * Description : This Function is Used For Update Product Status According To Parameter
  968.      *
  969.      * @Route("/check-duplicate-sku",
  970.      * name="officebrain_product_check_duplicate_sku")
  971.      */
  972.     public function checkDuplicateSKU(Request $request){
  973.         $this->init($request);
  974.         $sku $this->request->get('sku');
  975.         $supplierId $this->request->get('supplier_id');
  976.         $productId $this->request->get('product_id','');
  977.         $data $this->productApiManager->checkDuplicateSKU($sku,$supplierId,$productId);
  978.         $data['message'] = $this->translator->trans('product.'.$data['message']);
  979.         return new JsonResponse($data);
  980.     }
  981.     
  982.     /**
  983.      * @author Employee Id: 5190
  984.      * Description : This function used for List Matrix Information
  985.      * @Route("/matrix/list",
  986.      * name="officebrain_product_matrix_list")
  987.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/listMatrix.html.twig")
  988.      */
  989.     public function listMatrixAction(Request $request){
  990.         $this->init($request);
  991.         $projectSetting $this->request->get('project_setting');
  992.         $projectId $projectSetting['project_id'];
  993.         $data['matrix_data'] = $this->productApiManager->getMatrixList($projectId);
  994.         return array('data'=>$data);
  995.     }
  996.     
  997.     /**
  998.      * @author Employee Id: 5540
  999.      *
  1000.      * Description : This function used to Edit Product Information
  1001.      * @return array
  1002.      * @Route("/copy/{master_product_id}/{supplier_id}", name="officebrain_product_copy"),
  1003.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/add.html.twig")
  1004.      */
  1005.     public function copyProductAction(Request $request)
  1006.     {
  1007.         //$this->init($request);
  1008.         $supplierId $request->get('supplier_id');
  1009.         $productId $request->get('master_product_id','');
  1010.         $projectSetting $request->get('project_setting');
  1011.         // $returnData = $this->serviceContainer->get("office_brain_product_admin_manager")->copy($supplierId, $productId);
  1012.         $returnData $this->productApiManager->copy($supplierId$productId);
  1013.         $returnData = array('status' => 'success');
  1014.          
  1015.         /*
  1016.         //SOLR SYNC CODE START
  1017.             $is_solr_syn_enabled = $this->container->getParameter('solr_sync');
  1018.                 if($is_solr_syn_enabled)
  1019.                 {
  1020.                 $env = $this->container->getParameter("kernel.environment");
  1021.                 $localization_to_update = $this->container->getParameter('localization_to_fetch');
  1022.                 $this->get("office_brain_product_admin_manager")->updateSolrData($newProductId,$localization_to_update,$projectSetting['project_id'],$env,$projectSetting['instance_id'],'update');
  1023.             }
  1024.         //SOLR SYNC CODE END
  1025.         */
  1026.          
  1027.         if($returnData['status'] == 'success')
  1028.         {
  1029.             $data['status'] = 'success_message';
  1030.             $data['message'] = $this->serviceContainer->get('translator')->trans('product_add_edit.product_copied_successfully');
  1031.         }
  1032.         else
  1033.         {
  1034.             $data['status'] = 'error_message';
  1035.             $data['message'] = $this->serviceContainer->get('translator')->trans('product_add_edit.product_not_copied');
  1036.         }
  1037.          
  1038.         return new JsonResponse($data);
  1039.     }
  1040.     
  1041.     /**
  1042.      * @author Employee Id: 5190
  1043.      *
  1044.      * Description : This function used for Export Product data culture and country wise
  1045.      * @return array
  1046.      * @Route("/export", name="officebrain_product_export"),
  1047.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/export.html.twig")
  1048.      */
  1049.     public function exportAction(Request $request)
  1050.     {
  1051.         $this->init($request);
  1052.         $projectSetting $this->request->get('project_setting');
  1053.         $projectId $projectSetting['project_id'];
  1054.         list($defaultCulture,$defaultCountry) = explode("_",$this->request->get("_locale"));
  1055.         $culture $this->request->get('language',$defaultCulture);
  1056.         $country $this->request->get('country',$defaultCountry);
  1057.         $supplier_id $this->request->query->get('supplier_id','');
  1058.         $countryArray $this->serviceContainer->getParameter('country');
  1059.         $languageArray $this->serviceContainer->getParameter('language');
  1060.         $supplierData $this->productApiManager->getSupplierNameList($projectId);
  1061.         $instanceType $projectSetting['instance_type'];
  1062.         // if ($this->user->getUserType()=='admin' && $instanceType=='association'){ // symfony 4
  1063.         if ($this->user && $this->user->getUserType()=='admin' && $instanceType=='association'){
  1064.             $supplier_id $this->request->query->get('supplier_id','');
  1065.         // } else if($this->user && $this->user->getUserType()=='supplier' || $this->user->getUserType()=='distributor' || ($this->user->getUserType() == 'admin' && $instanceType == 'distributor') || ($this->user->getUserType() == 'admin' && $instanceType == 'supplier')){ // symfony 4
  1066.         } elseif ($this->user && (
  1067.             $this->user->getUserType() == 'supplier' || 
  1068.             $this->user->getUserType() == 'distributor' || ( 
  1069.                 $this->user->getUserType() == 'admin' && (
  1070.                     $instanceType == 'distributor' || 
  1071.                     $instanceType == 'supplier'
  1072.                 
  1073.             ) 
  1074.         ) ) {
  1075.             $supplier_id $this->user->getObCustomerId();
  1076.             $supplier_id str_replace(array('OB','ob'), ''$supplier_id);
  1077.     
  1078.             if(empty($supplier_id)){
  1079.                 $supplier_id 0;
  1080.             }
  1081.         }else{
  1082.             $supplier_id 0;
  1083.         }
  1084.     
  1085.         foreach($countryArray as $countryKey => $country){
  1086.             $data['country_data'][] = array('id'=>$country['id'],'code'=>$country['short_name'],'title'=>$country['name'],'language'=>$country['language']);
  1087.         }
  1088.     
  1089.         if ($this->request->isXmlHttpRequest() && $this->request->getMethod()=='POST') {
  1090.             $data $this->request->request->all();
  1091.             $apiResponse =  $this->productApiManager->getExportProduct($data);
  1092.     
  1093.             return new JsonResponse($apiResponse);
  1094.         }
  1095.         $data['project_id']= $projectId;
  1096.         $data['country_array'] = $countryArray;
  1097.         $data['language_data'] = $languageArray;
  1098.         $data['supplier_data'] = $supplierData;
  1099.         $data['INSTANCE_TYPE'] = $instanceType;
  1100.         $data['supplier_id']=$supplier_id;
  1101.     
  1102.         return array('data'=>$data);
  1103.     
  1104.     }
  1105.     /**
  1106.      * @author Employee Id: 5190
  1107.      *
  1108.      * Description : This function used for Import Product data supplier, culture and country wise
  1109.      * @return array
  1110.      * @Route("/import", name="officebrain_product_import"),
  1111.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/import.html.twig")
  1112.      */
  1113.     
  1114.     public function importAction(Request $request){
  1115.         $this->init($request);
  1116.         $projectSetting $this->request->get('project_setting');
  1117.         $projectId $projectSetting['project_id'];
  1118.         list($defaultCulture,$defaultCountry) = explode("_",$this->request->get("_locale"));
  1119.         $culture $this->request->get('language',$defaultCulture);
  1120.         $country $this->request->get('country',$defaultCountry);
  1121.         $supplier_id $this->request->query->get('supplier_id','');
  1122.         //echo $supplier_id;die;
  1123.          
  1124.         $countryArray $this->serviceContainer->getParameter('country');
  1125.         $languageArray $this->serviceContainer->getParameter('language');
  1126.     
  1127.         $supplierData $this->productApiManager->getSupplierNameList($projectId);
  1128.         $instanceType $projectSetting['instance_type'];
  1129.         if ($this->user && $this->user->getUserType()=='admin' && $instanceType=='association'){
  1130.             $supplier_id $this->request->query->get('supplier_id','');
  1131.         // } else if($this->user->getUserType()=='supplier' || $this->user->getUserType()=='distributor' || ($this->user->getUserType() == 'admin' && $instanceType == 'distributor') || ($this->user->getUserType() == 'admin' && $instanceType == 'supplier')){ // symfony 4
  1132.         } elseif ($this->user && (
  1133.             $this->user->getUserType() == 'supplier' || 
  1134.             $this->user->getUserType() == 'distributor' || ( 
  1135.                 $this->user->getUserType() == 'admin' && (
  1136.                     $instanceType == 'distributor' || 
  1137.                     $instanceType == 'supplier'
  1138.                 
  1139.             ) 
  1140.         ) ) {
  1141.             $supplier_id $this->user->getObCustomerId();
  1142.             $supplier_id str_replace(array('OB','ob'), ''$supplier_id);
  1143.             if(empty($supplier_id)){
  1144.                 $supplier_id 0;
  1145.             }
  1146.         }else{
  1147.             $supplier_id 0;
  1148.         }
  1149.         foreach($countryArray as $countryKey => $country){
  1150.             $data['country_data'][] = array('id'=>$country['id'],'code'=>$country['short_name'],'title'=>$country['name'],'language'=>$country['language']);
  1151.         }
  1152.     
  1153.         if ($this->request->isXmlHttpRequest() && $this->request->getMethod()=='POST') {
  1154.             $uploadImportFilePath $this->serviceContainer->getParameter('tmp_image_upload_path');;
  1155.             $allwedImportFileMimeType $this->serviceContainer->getParameter('allowed_import_file_mime_type');
  1156.             $translator $this->serviceContainer->get('translator');
  1157.             //echo $uploadImportFilePath;die;
  1158.             if(!IS_DIR($uploadImportFilePath)){
  1159.                 mkdir($uploadImportFilePath,0777,true);
  1160.             }
  1161.     
  1162.             $importFileName '';
  1163.             $error false;
  1164.             $supplierId $this->request->get('supplier_id','');
  1165.             $countryId $this->request->get('country_id','');
  1166.             $cultureId $this->request->get('culture_id','');
  1167.             $userId $this->userId;
  1168.             //echo $supplierId.'---'.$countryId.'---'.$cultureId.'--'.$userId;die;
  1169.             if(!empty($_FILES) && $countryId >&& $cultureId >&& $supplierId>0){
  1170.                 foreach($_FILES as $file)
  1171.                 {
  1172.                     $filename $file['name'];
  1173.                     $extension pathinfo($filenamePATHINFO_EXTENSION);
  1174.                     if($extension != 'xls'){
  1175.                         $error true;
  1176.                         $error_message $translator->trans('product_import_export.allowed_import_file_type');
  1177.                     }
  1178.                     
  1179.                     if(!$error){
  1180.                         $importFileName "import_supplierid_".$supplierId."_countryid_".$countryId."_cultureid_".$cultureId."_".time().".".$extension;
  1181.                         $uploadImportFile $uploadImportFilePath.$importFileName;
  1182.                         $file_moved = @move_uploaded_file($file['tmp_name'], $uploadImportFile);
  1183.                         
  1184.                         if($file_moved){
  1185.                             $response $this->productApiManager->uploadImportFile($supplierId,$countryId,$cultureId,$projectId,$uploadImportFile,$uploadImportFilePath$userId);
  1186.                                                                     
  1187.                             if($response['status'] == 'success'){
  1188.                                 if(file_exists($uploadImportFile)){
  1189.                                     @unlink($uploadImportFile);
  1190.                                 }
  1191.                                 $error false;
  1192.                                 $success_message $translator->trans('product_import_export.import_process_start');
  1193.                             }
  1194.                             else{
  1195.                                 $error true;
  1196.                                 $error_message $translator->trans('product_import_export.file_upload_error_message');
  1197.                             }
  1198.                         }
  1199.                         else {
  1200.                             $error true;
  1201.                             $error_message $translator->trans('product_import_export.file_upload_error_message'); 
  1202.                         }
  1203.                     }
  1204.                 }
  1205.             }
  1206.  
  1207.             
  1208.             else{
  1209.                 $error true;
  1210.                 $error_message $translator->trans('product.file_not_found');   //"Please select file" ;
  1211.             }
  1212.     
  1213.             if(!$error){
  1214.                 $return = array (
  1215.                         'status' => 'success',
  1216.                         'success_message'=> $success_message,
  1217.                 );
  1218.             } else {
  1219.                 $return = array (
  1220.                         'status' => 'error',
  1221.                         'error_message' => $error_message);
  1222.             }
  1223.     
  1224.             return new JsonResponse($return);
  1225.         }
  1226.     
  1227.         $data['country_array'] = $countryArray;
  1228.         $data['language_data'] = $languageArray;
  1229.         $data['supplier_data'] = $supplierData;
  1230.         $data['INSTANCE_TYPE'] = $instanceType;
  1231.         $data['supplier_id']=$supplier_id;
  1232.     
  1233.         return array('data'=>$data);
  1234.     
  1235.     }
  1236.     
  1237.     /**
  1238.      * @author Employee Id: 5190
  1239.      *
  1240.      * Description : This function used for Import Product data supplier, culture and country wise
  1241.      * @return array
  1242.      * @Route("/check_import_status", name="officebrain_product_check_import_status"),
  1243.      * options={"expose"=true},
  1244.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/checkImportStatus.html.twig")
  1245.      */
  1246.     
  1247.     public function checkImportStatusAction(Request $request){
  1248.         $this->init($request);
  1249.         $supplierId $request->get('supplier_id');
  1250.         $projectSetting $this->request->get('project_setting');
  1251.         $projectId $projectSetting['project_id'];
  1252.     
  1253.         $returnData $this->productApiManager->checkImportStatus($supplierId,$projectId);
  1254.     
  1255.         return array('data'=>$returnData);
  1256.     
  1257.     }
  1258.     
  1259.     /**
  1260.      * @author Employee Id: 5190
  1261.      *
  1262.      * Description : This function used for add inventory message sku colour wise
  1263.      * @return array
  1264.      * @Route("/get-inventory-message/{sku}", name="officebrain_product_add_inventory_message"),
  1265.      * options={"expose"=true},
  1266.      */
  1267.     public function addInventoryMessageAction(Request $request){
  1268.         $this->init($request);
  1269.         $sku $request->get('sku');
  1270.         $data json_encode(array('message'=>'','sku'=>$sku));
  1271.         $obj $this->productApiManager->getInvMessageBySku($sku);
  1272.         //var_dump($obj); die;
  1273.         if(count($obj)>0){ 
  1274.             $data =  json_encode(array('message'=>$obj[0]->getMessage(),'sku'=>$obj[0]->getProductSku()));
  1275.         }
  1276.         echo $data;
  1277.         die;  
  1278.         //$this->productApiManager;
  1279.     }
  1280.     
  1281.     /**
  1282.      * @author Employee Id: 5190
  1283.      *
  1284.      * Description : This function used for add inventory message sku colour wise
  1285.      * @return array
  1286.      * @Route("/add-inventory-message", name="officebrain_product_update_inventory_message"),
  1287.      * options={"expose"=true},
  1288.      */
  1289.     public function updateInventoryMessageAction(Request $request){
  1290.         $this->init($request);
  1291.         $parameters $request->request->all();
  1292.         /*if($parameters['inv_message']==""){
  1293.          $data = json_encode(array('status'=>'error_message','message'=>'Enter Message'));
  1294.          }else{*/
  1295.         $object null;
  1296.         $message $parameters['inv_message'];
  1297.         $sku $parameters['inv_sku'];
  1298.         $obj $this->productApiManager->getInvMessageBySku($sku);
  1299.         if(count($obj)>0){
  1300.             $object $obj[0];
  1301.         }
  1302.         $this->productApiManager->updateMessage($object,$message,$sku);
  1303.         $data json_encode(array('status'=>'success_message','message'=>'Message added successfully'));
  1304.         //}
  1305.         echo $data;
  1306.         die;
  1307.     }
  1308.     /**
  1309.      * @author Employee Id: 5190
  1310.      *
  1311.      * Description : This function used for get importErrorLog using importId.
  1312.      * @return array
  1313.      * @Route("/import_error_log/{import_id}", name="officebrain_product_import_error_log"),
  1314.      * @Template("")
  1315.      */
  1316.     
  1317.     public function importErrorLogAction(Request $request){
  1318.         $this->init($request);
  1319.         $importId $request->get('import_id');
  1320.         $returnData $this->productApiManager->importErrorLog($importId);
  1321.         $filename "import_error_log_" $importId.".csv";
  1322.         $response $this->render('OfficeBrain/Bundle/ProductBundle/ProductAdmin/importErrorLog.csv.twig',array('data' => $returnData));
  1323.         //$response->setStatusCode(200);
  1324.         $response->headers->set('Content-Type''text/csv');
  1325.         $response->headers->set('Content-Disposition''attachment; filename="'.$filename.'"');
  1326.         $response->headers->set('Pragma''no-cache');
  1327.         $response->headers->set('Expires''0');
  1328.         //$response->sendHeaders();
  1329.         //$response->sendContent();
  1330.         return $response;
  1331.     
  1332.         //return array('data'=>$returnData);
  1333.     }
  1334.     
  1335.     
  1336.     /**
  1337.      * @Route("/suggestedProduct/{id}",
  1338.      * name="officebrain_product_bundle_get_suggested_product",
  1339.      * options={"expose"=true}, methods={"GET"})
  1340.      */
  1341.     public function getSuggestedProductByProductIdAction(Request $request$id){
  1342.         $this->init($request);
  1343.         $data $this->productApiManager->getSuggestedProductByProductId($id);
  1344.         
  1345.         return new JsonResponse($data);
  1346.     }
  1347.     
  1348.     /**
  1349.      * @Route("/suggestedProduct/{id}",
  1350.      * name="officebrain_product_bundle_set_suggested_product",
  1351.      * options={"expose"=true}, methods={"POST"})
  1352.      */
  1353.     public function setSuggestedProductByProductIdAction(Request $request$id){
  1354.         $this->init($request);
  1355.         $pmsId $id;
  1356.         $productsSku $this->request->get('products_sku');
  1357.         //         $products =
  1358.         $api_manager $this->serviceContainer->get('officebrain_category_api_manager');
  1359.         $data $this->productApiManager->setSuggestedProductByProductId($pmsId,$productsSku);
  1360.         $data['message'] = $this->translator->trans($data['message']);
  1361.         return new JsonResponse($data);
  1362.     }
  1363.     
  1364.     /**
  1365.      * @author Employee Id: 5429
  1366.      *
  1367.      * Description : This function used for add inventory message sku colour wise
  1368.      * @return array
  1369.      * @Route("/get-rsync-status/{sku}/{slug}", name="officebrain_product_rsync_check"),
  1370.      * options={"expose"=true},
  1371.      */
  1372.    public function getRsyncStatusAction(Request $request){
  1373.         $this->init($request);
  1374.         $sku $request->get('sku');
  1375.         $slug $request->get('slug');
  1376.         $this->productDetailManager->updateSyncDetail(1,$sku);
  1377.         //$asiurl = 'http://demoapi.officebrain.com/update_product_api.php?product_slug=16-oz-victory-acrylic-tumbler-with-straw-lid-full-color-digital';
  1378.         //$result = exec("curl '$asiurl' > /dev/null &",$output,$return_val);
  1379.         $asiurl 'https://demoapi.officebrain.com/update_product_api.php?product_slug='.$slug;
  1380.        //$asiurl = 'http://demoapi.officebrain.com/update_product_api.php?product_slug=halcyon-r-waterproof-wireless-speaker-full-color-digital';
  1381.       
  1382.         $curl curl_init();
  1383.         curl_setopt_array($curl, array(
  1384.           CURLOPT_URL => $asiurl,
  1385.           CURLOPT_RETURNTRANSFER => true,
  1386.           CURLOPT_ENCODING => '',
  1387.           CURLOPT_MAXREDIRS => 10,
  1388.           CURLOPT_TIMEOUT => 0,
  1389.           CURLOPT_FOLLOWLOCATION => true,
  1390.           CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  1391.           CURLOPT_CUSTOMREQUEST => 'GET',
  1392.           CURLOPT_SSL_VERIFYPEER =>0
  1393.         ));
  1394.         $response curl_exec($curl); 
  1395.         if (curl_errno($curl)) {
  1396.             echo $error_msg curl_error($curl); die;
  1397.         }
  1398.         curl_close($curl); 
  1399.         echo $response;
  1400.        /* $result = exec("curl '$asiurl' 2>&1 &", $output);
  1401.         if(isset($output[3]) && $output[3]!=''){
  1402.             $msg = json_decode($output[3]);
  1403.             $reason = $msg->Errors[0]->Reason;
  1404.             $data = json_encode(array('status'=>'success_message','message'=>'Reason:'.$reason));
  1405.         }else{
  1406.             $data = json_encode(array('status'=>'success_message','message'=>'Product Sync Successfully'));
  1407.         }*/
  1408.        // echo $data;
  1409.         die;
  1410.     }
  1411.     
  1412.     /**
  1413.      * @author Employee Id: 5429
  1414.      *
  1415.      * Description : This function used for add imprint method on skus
  1416.      * @return array
  1417.      * @Route("/imprint-skus", name="officebrain_imprint_skus_product"),
  1418.      * @Template("OfficeBrain/Bundle/ProductBundle/ProductAdmin/getImprintSkus.html.twig")
  1419.      */
  1420.     public function getImprintSkusAction(Request $request){
  1421.         $searchParameters = array();
  1422.         // $productTagManager = $this->serviceContainer->get('office_brain_product_tag_manager');
  1423.         $productTagManager $this->productTagManager;
  1424.         if(!empty($_REQUEST['sku']) && $_REQUEST['sku']!=""){
  1425.             $culture $request->get('_locale','en_us');
  1426.             // $productDetailManager = $this->serviceContainer->get('office_brain_product_detail_manager');
  1427.             $productDetailManager $this->productDetailManager;
  1428.             $productObj $productDetailManager->getProductDetailBySku($_REQUEST['sku'], 5,$culture,false);
  1429.             if(isset($productObj['product_id'])){
  1430.                 $data['product_id'] = $productObj['product_id'];
  1431.                 $data['imprint'] = $_REQUEST['imprint'];
  1432.                 $data['sku'] = $productObj['basic_information']['sku_number'];
  1433.                 $data['product_title'] = $productObj['basic_information']['title'];
  1434.                 $data['product_image'] = $productObj['basic_information']['default_image_thumb_url'];
  1435.                 $productImprint $productTagManager->getImprintProductByIdAndMethod($data['product_id'],$data['imprint']);
  1436.                 if($productImprint==NULL){
  1437.                     $productTagManager->addImprintProduct($data);
  1438.                      //SOLR SYNC CODE START
  1439.                     // $productApiManager = $this->serviceContainer->get("office_brain_product_admin_manager");
  1440.                     $productApiManager $this->productApiManager;
  1441.                     $is_solr_syn_enabled $this->serviceContainer->getParameter('solr_sync');
  1442.                     if($is_solr_syn_enabled){
  1443.                         $env $this->serviceContainer->getParameter("kernel.environment");
  1444.                         $localization_to_update $this->serviceContainer->getParameter('localization_to_fetch');
  1445.                         $productApiManager->updateSolrData($data['product_id'],$localization_to_update,5,$env,'update');
  1446.                     }
  1447.                     
  1448.                     //SOLR SYNC CODE END
  1449.                 
  1450.                     $this->get('session')->getflashbag()->add('success_message''Sku mapped successfully.');
  1451.                 }else{
  1452.                     $this->get('session')->getflashbag()->add('error_message''Sku already mapped.');
  1453.                     return $this->redirect($this->generateUrl('officebrain_imprint_skus_product'));
  1454.                 }
  1455.             }
  1456.                 
  1457.         }
  1458.         $searchParameters['search_result_array']['data'] = $productTagManager->getAllImprintProducts();
  1459.         // $this->arrayToPaginationManager = $this->serviceContainer->get('office_brain_array_to_pagination_manager');
  1460.         $this->arrayToPaginationManager $this->arrayToPaginationManager;
  1461.         if(!empty($searchParameters['search_result_array'])){
  1462.             $this->arrayToPaginationManager->setPaginationArray($searchParameters['search_result_array']);
  1463.             $this->arrayToPaginationManager->doConvert();
  1464.             $searchParameters['pagination'] = $this->arrayToPaginationManager->getPagination();
  1465.         }
  1466.         return $searchParameters;
  1467.     }
  1468.     
  1469.     /**
  1470.      * @author Employee Id: 5429
  1471.      *
  1472.      * Description : This function used for add imprint method on skus
  1473.      * @return array
  1474.      * @Route("/remove-imprint-skus/{id}", name="officebrain_product_remove_imprint_skus"),
  1475.      */
  1476.     public function removeImprintSkusAction(Request $request){
  1477.         $id $request->get('id');
  1478.         $productTagManager $this->productTagManager;
  1479.         $prodData $productTagManager->getImprintProductById($id);
  1480.         if($prodData!=NULL){
  1481.              $productId $prodData->getProductId();
  1482.              $productTagManager->deleteImprintProductById($prodData);
  1483.               //SOLR SYNC CODE START
  1484.                     // $productApiManager = $this->serviceContainer->get("office_brain_product_admin_manager");
  1485.                     $productApiManager $this->productApiManager;
  1486.                     $is_solr_syn_enabled $this->serviceContainer->getParameter('solr_sync');
  1487.                     if($is_solr_syn_enabled){
  1488.                         $env $this->serviceContainer->getParameter("kernel.environment");
  1489.                         $localization_to_update $this->serviceContainer->getParameter('localization_to_fetch');
  1490.                         $productApiManager->updateSolrData($productId,$localization_to_update,5,$env,'update');
  1491.                     }
  1492.                     
  1493.                     //SOLR SYNC CODE END
  1494.              $this->get('session')->getflashbag()->add('success_message''Record deleted successfully.');
  1495.         }else{
  1496.             $this->get('session')->getflashbag()->add('error_message''no record found');
  1497.         }
  1498.         return $this->redirect($this->generateUrl('officebrain_imprint_skus_product'));
  1499.     }
  1500.     
  1501. }