src/OfficeBrain/Bundle/SearchBundle/Form/Data/ProductSearchData.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\OfficeBrain\Bundle\SearchBundle\Form\Data;
  3. use Symfony\Component\Validator\Constraints as Assert;
  4. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  5. use Doctrine\ORM\EntityManager;
  6. use OfficeBrain\Bundle\CategoryBundle\Entity\CultureCategory;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. class ProductSearchData
  9. {
  10.     private $country;
  11.     private $tag;
  12.     private $categoryId;
  13.     private $categorySlug;
  14.     private $supplierId;
  15.     private $brandId;
  16.     private $minPrice;
  17.     private $minPriceWithoutLogin;
  18.     private $maxPrice;
  19.     private $minQty;
  20.     private $maxQty;
  21.     private $pageNumber;
  22.     private $sortOn;
  23.     private $sortOrder;
  24.     private $keyword;
  25.     private $attribute;
  26.     private $sort;
  27.     private $searchType;
  28.     private $catalogYear;
  29.     private $priceValidUntil;
  30.     // TODO added for promocan api
  31.     private $lineNameId;
  32.     private $priceCurrency;
  33.     private $quantity;
  34.     private $sku;
  35.     private $em;
  36.     private $languageCode;
  37.     private $callForPrice;
  38.     private $lineName;
  39.     private $categoryName;
  40.     private $postName;
  41.     private $supplierName;
  42.     private $supplier;
  43.     private $distributorId;
  44.     private $customCategoryId;
  45.     private $productId;
  46.     private $instanceId;
  47.     
  48.     private $userRole;
  49.     private $userId;
  50.     private $rating;
  51.     private $productAttribute;
  52.     
  53.     private $publicCustomTagText;
  54.     private $privateCustomTagText;
  55.     
  56.     private $colorMapping;
  57.     private $serviceGroupId;
  58.     
  59.     private $categoryIdNot;
  60.     private $productIdNot;
  61.     private $tagNot;
  62.     private $categoryTagId;
  63.     private $categoryTag;
  64.     private $quoteSearch;
  65.     
  66.     private $similarSku;
  67.     
  68.     public function __construct(EntityManager $em$languageCode '1')
  69.     {
  70.         $this->em $em;
  71.         $this->languageCode $languageCode;
  72.     }
  73.     public static function toSolrSupportedArray($object)
  74.     {
  75.         $returnArray = array();
  76.         foreach (get_class_vars(get_class($object)) as $key=>$value) {
  77.             $tmpKey =  trim(strtolower(preg_replace('/([a-z])([A-Z])/''$1_$2'$key)));
  78.             $returnArray[$tmpKey] = (in_array($key, array( "brandId"))? (isset($object->$key)?array($object->$key):null) : $object->$key);
  79.         }
  80.         return $returnArray;
  81.     }
  82.     /**
  83.      * @Assert\Callback
  84.      */
  85.     public function validate(ExecutionContextInterface $context)
  86.     {
  87.         if ($this->getCategorySlug()!="") {
  88.             $result $this->em->getRepository('App\OfficeBrain\Bundle\CategoryBundle\Entity\CultureCategory')->findOneBy(array('slug'=>$this->getCategorySlug(), 'culture'=>$this->languageCode));
  89.             if (!$result) {
  90.                 $context->addViolationAt(
  91.                         'categorySlug',
  92.                         'Please provide valid category slug.',
  93.                         array(),
  94.                         null
  95.                 );
  96.             } else {
  97.                 $this->setCategoryId($result->getCat()->getId());
  98.             }
  99.         }
  100.     }
  101.     
  102.     public function getCategoryTagId()
  103.     {
  104.         return $this->categoryTagId;
  105.     }
  106.     
  107.     public function setCategoryTagId($categoryTagId)
  108.     {
  109.         $this->categoryTagId $categoryTagId;
  110.         return $this;
  111.     }
  112.     
  113.     public function getCategoryTag()
  114.     {
  115.         return $this->categoryTag;
  116.     }
  117.     
  118.     public function setCategoryTag($categoryTag)
  119.     {
  120.         $this->categoryTag $categoryTag;
  121.         return $this;
  122.     }
  123.     public function getQuoteSearch()
  124.     {
  125.         return $this->quoteSearch;
  126.     }
  127.     
  128.     public function setQuoteSearch($quoteSearch)
  129.     {
  130.         $this->quoteSearch $quoteSearch;
  131.         return $this;
  132.     }
  133.     
  134.     
  135.     /************************************Solr call api starts*******************************************/
  136.     public function init($apiCallType)
  137.     {
  138.         $this->isError false;
  139.         $this->apiCallType trim($apiCallType);
  140.     }
  141.     
  142.     public function setSearchKeyword($searchKeyword)
  143.     {
  144.         $this->searchKeyword trim($searchKeyword);
  145.     }
  146.     
  147.     public function setAttributeFilter($attributeFilter)
  148.     {
  149.         $attributeFilter trim($attributeFilter);
  150.         if ($attributeFilter) {
  151.             $this->attributeFilter $this->parseAttribute($attributeFilter);
  152.         }
  153.     }
  154.     
  155.     private function parseAttribute($attributeFilter)
  156.     {
  157.         $attributeFilterArray = array();
  158.         $attributeFilter json_decode($attributeFilter);
  159.     
  160.         foreach ($attributeFilter as $filterData) {
  161.             $filterData explode('-'$filterData);
  162.             $attributeFilterArray[$filterData[0]][] = $filterData[1];
  163.         }
  164.         return json_encode($attributeFilterArray);
  165.     }
  166.     
  167.     public function setServiceGroupId($id)
  168.     {
  169.         return $this->serviceGroupId $id;
  170.     }
  171.     public function getServiceGroupId()
  172.     {
  173.         return $this->serviceGroupId;
  174.     }
  175.     
  176.     /* Similar Sku */
  177.     public function setSimilarSku($similarSku)
  178.     {
  179.         return $this->similarSku $similarSku;
  180.     }
  181.     public function getSimilarSku()
  182.     {
  183.         return $this->similarSku;
  184.     }
  185.     /* Similar Sku */
  186.     
  187.     /******************************************Solr call api ends**************************************************/
  188.     /******************************************set category filter starts**************************************************/
  189.         
  190.     public function setCategoryFilter($categoryFilter)
  191.     {
  192.         $categoryFilter trim($categoryFilter);
  193.         if ($categoryFilter) {
  194.             $this->categoryFilter $this->parseCategoryFilterAttribute($categoryFilter);
  195.         }
  196.     }
  197.     
  198.     private function parseCategoryFilterAttribute($categoryFilter)
  199.     {
  200.         $categoryFilterArray = array();
  201.         $categoryFilter json_decode($categoryFilter);
  202.         return json_encode($categoryFilter);
  203.     }
  204.     
  205.     public function setBrandFilter($brandFilter)
  206.     {
  207.         $brandFilter trim($brandFilter);
  208.         if ($brandFilter) {
  209.             $this->brandFilter $this->parseBrandFilterAttribute($brandFilter);
  210.         }
  211.     }
  212.     
  213.     private function parseBrandFilterAttribute($brandFilter)
  214.     {
  215.         $brandFilterArray = array();
  216.         $brandFilter json_decode($brandFilter);
  217.         return json_encode($brandFilter);
  218.     }
  219.     
  220.     /******************************************set category filter ends**************************************************/
  221.     /******************************************set sort starts**************************************************/
  222.     public function setSortBy($sortBy)
  223.     {
  224.         $this->sortBy trim($sortBy);
  225.         if ($this->sortBy) {
  226.             $sortBy explode('::'$this->sortBy);
  227.             $this->sortField $sortBy[0];
  228.             $this->sortOrder strtoupper($sortBy[1]);
  229.         }
  230.     }
  231.     
  232.     /******************************************set sort ends**************************************************/
  233.     /******************************************Feature starts**************************************************/
  234.     public function setNewProduct($newProduct)
  235.     {
  236.         $this->newProduct = ($newProduct)?'yes':'';
  237.     }
  238.     
  239.     public function setFeaturedProduct($featuredProduct)
  240.     {
  241.         $this->featuredProduct = ($featuredProduct)?'yes':'';
  242.     }
  243.     
  244.     public function setSaleProductAdd($addSaleProduct)
  245.     {
  246.         $this->addSale $addSaleProduct;
  247.     }
  248.     
  249.     public function setCloseoutProduct($closeoutProduct)
  250.     {
  251.         $this->closeoutProduct = ($closeoutProduct)?'yes':'';
  252.     }
  253.     
  254.     public function setSaleCloseoutProduct($saleCloseoutProduct)
  255.     {
  256.         $this->saleCloseoutProduct = ($saleCloseoutProduct)?'yes':'';
  257.     }
  258.     
  259.     /******************************************Featured ends**************************************************/
  260.     
  261.     public function setProductPerPage($productPerPage)
  262.     {
  263.         $this->productPerPage trim($productPerPage);
  264.     }
  265.     
  266.     public function getCountry()
  267.     {
  268.         return $this->country;
  269.     }
  270.     public function setCountry($country)
  271.     {
  272.         $this->country $country;
  273.         return $this;
  274.     }
  275.     public function getTag()
  276.     {
  277.         return $this->tag;
  278.     }
  279.     public function setTag($tag)
  280.     {
  281.         $this->tag $tag;
  282.         return $this;
  283.     }
  284.     public function getCategoryId()
  285.     {
  286.         return $this->categoryId;
  287.     }
  288.     public function setCategoryId($categoryId)
  289.     {
  290.         $this->categoryId $categoryId;
  291.         return $this;
  292.     }
  293.     public function getColorMapping()
  294.     {
  295.         return $this->colorMapping;
  296.     }
  297.     
  298.     public function setColorMapping($colorMapping)
  299.     {
  300.         $this->colorMapping $colorMapping;
  301.         return $this;
  302.     }
  303.     
  304.     public function getSupplierId()
  305.     {
  306.         return $this->supplierId;
  307.     }
  308.     public function setSupplierId($supplierId)
  309.     {
  310.         $this->supplierId $supplierId;
  311.         return $this;
  312.     }
  313.     public function getBrandId()
  314.     {
  315.         return $this->brandId;
  316.     }
  317.     public function setBrandId($brandId)
  318.     {
  319.         $this->brandId $brandId;
  320.         return $this;
  321.     }
  322.     public function getMinPrice()
  323.     {
  324.         return $this->minPrice;
  325.     }
  326.     public function setMinPrice($minPrice)
  327.     {
  328.         $this->minPrice $minPrice;
  329.         return $this;
  330.     }
  331.     public function getMinPriceWithoutLogin()
  332.     {
  333.         return $this->minPriceWithoutLogin;
  334.     }
  335.     public function setMinPriceWithoutLogin($minPriceWithoutLogin)
  336.     {
  337.         $this->minPriceWithoutLogin $minPriceWithoutLogin;
  338.         return $this;
  339.     }
  340.     public function getMaxPrice()
  341.     {
  342.         return $this->maxPrice;
  343.     }
  344.     public function setMaxPrice($maxPrice)
  345.     {
  346.         $this->maxPrice $maxPrice;
  347.         return $this;
  348.     }
  349.     public function getMinQty()
  350.     {
  351.         return $this->minQty;
  352.     }
  353.     public function setMinQty($minQty)
  354.     {
  355.         $this->minQty $minQty;
  356.         return $this;
  357.     }
  358.     public function getMaxQty()
  359.     {
  360.         return $this->maxQty;
  361.     }
  362.     public function setMaxQty($maxQty)
  363.     {
  364.         $this->maxQty $maxQty;
  365.         return $this;
  366.     }
  367.     public function getPageNumber()
  368.     {
  369.         return $this->pageNumber;
  370.     }
  371.     public function setPageNumber($pageNumber)
  372.     {
  373.         $this->pageNumber $pageNumber;
  374.         return $this;
  375.     }
  376.     public function getSortOn()
  377.     {
  378.         return $this->sortOn;
  379.     }
  380.     public function setSortOn($sortOn)
  381.     {
  382.         $this->sortOn $sortOn;
  383.         return $this;
  384.     }
  385.     public function getSortOrder()
  386.     {
  387.         return $this->sortOrder;
  388.     }
  389.     public function setSortOrder($sortOrder)
  390.     {
  391.         $this->sortOrder $sortOrder;
  392.         return $this;
  393.     }
  394.     public function getKeyword()
  395.     {
  396.         return $this->keyword;
  397.     }
  398.     public function setKeyword($keyword)
  399.     {
  400.         $this->keyword $keyword;
  401.         return $this;
  402.     }
  403.     public function getAttribute()
  404.     {
  405.         return $this->attribute;
  406.     }
  407.     public function setAttribute($attribute)
  408.     {
  409.         $this->attribute $attribute;
  410.         return $this;
  411.     }
  412.     public function getSort()
  413.     {
  414.         return $this->sort;
  415.     }
  416.     public function setSort($sort)
  417.     {
  418.         $this->sort $sort;
  419.         return $this;
  420.     }
  421.     public function getCategorySlug()
  422.     {
  423.         return $this->categorySlug;
  424.     }
  425.     public function setCategorySlug($categorySlug)
  426.     {
  427.         $this->categorySlug $categorySlug;
  428.         return $this;
  429.     }
  430.     /**
  431.      * @param mixed $lineNameId
  432.      */
  433.     public function setLineNameId($lineNameId)
  434.     {
  435.         $this->lineNameId $lineNameId;
  436.     }
  437.     /**
  438.      * @return mixed
  439.      */
  440.     public function getLineNameId()
  441.     {
  442.         return $this->lineNameId;
  443.     }
  444.     /**
  445.      * @param mixed $searchType
  446.      */
  447.     public function setSearchType($searchType)
  448.     {
  449.         $this->searchType $searchType;
  450.     }
  451.     /**
  452.      * @return mixed
  453.      */
  454.     public function getSearchType()
  455.     {
  456.         return $this->searchType;
  457.     }
  458.     /**
  459.      * @param mixed $catalogYear
  460.      */
  461.     public function setCatalogYear($catalogYear)
  462.     {
  463.         $this->catalogYear $catalogYear;
  464.     }
  465.     /**
  466.      * @return mixed
  467.      */
  468.     public function getCatalogYear()
  469.     {
  470.         return $this->catalogYear;
  471.     }
  472.     /**
  473.      * @param mixed $priceValidUntil
  474.      */
  475.     public function setPriceValidUntil($priceValidUntil)
  476.     {
  477.         $this->priceValidUntil $priceValidUntil;
  478.     }
  479.     /**
  480.      * @return mixed
  481.      */
  482.     public function getPriceValidUntil()
  483.     {
  484.         return $this->priceValidUntil;
  485.     }
  486.     /**
  487.      * @param string $languageCode
  488.      */
  489.     public function setLanguageCode($languageCode)
  490.     {
  491.         $this->languageCode $languageCode;
  492.     }
  493.     /**
  494.      * @return string
  495.      */
  496.     public function getLanguageCode()
  497.     {
  498.         return $this->languageCode;
  499.     }
  500.     /**
  501.      * @param mixed $priceCurrency
  502.      */
  503.     public function setPriceCurrency($priceCurrency)
  504.     {
  505.         $this->priceCurrency $priceCurrency;
  506.     }
  507.     /**
  508.      * @return mixed
  509.      */
  510.     public function getPriceCurrency()
  511.     {
  512.         return $this->priceCurrency;
  513.     }
  514.     /**
  515.      * @param mixed $quantity
  516.      */
  517.     public function setQuantity($quantity)
  518.     {
  519.         $this->quantity $quantity;
  520.     }
  521.     /**
  522.      * @return mixed
  523.      */
  524.     public function getQuantity()
  525.     {
  526.         return $this->quantity;
  527.     }
  528.     /**
  529.      * @param mixed $sku
  530.      */
  531.     public function setSku($sku)
  532.     {
  533.         $this->sku $sku;
  534.     }
  535.     /**
  536.      * @return mixed
  537.      */
  538.     public function getSku()
  539.     {
  540.         return $this->sku;
  541.     }
  542.     /**
  543.      * @param mixed $callForPrice
  544.      */
  545.     public function setCallForPrice($callForPrice)
  546.     {
  547.         $this->callForPrice $callForPrice;
  548.     }
  549.     /**
  550.      * @return mixed
  551.      */
  552.     public function getCallForPrice()
  553.     {
  554.         return $this->callForPrice;
  555.     }
  556.     /**
  557.      * @param mixed $lineName
  558.      */
  559.     public function setLineName($lineName)
  560.     {
  561.         $this->lineName $lineName;
  562.     }
  563.     /**
  564.      * @return mixed
  565.      */
  566.     public function getLineName()
  567.     {
  568.         return $this->lineName;
  569.     }
  570.     /**
  571.      * @param mixed $categoryName
  572.      */
  573.     public function setCategoryName($categoryName)
  574.     {
  575.         $this->categoryName $categoryName;
  576.     }
  577.     /**
  578.      * @return mixed
  579.      */
  580.     public function getCategoryName()
  581.     {
  582.         return $this->categoryName;
  583.     }
  584.     
  585.     /**
  586.      * @param mixed $postName
  587.      */
  588.     public function setPostName($postName)
  589.     {
  590.         $this->postName $postName;
  591.     }
  592.     /**
  593.      * @return mixed
  594.      */
  595.     public function getPostName()
  596.     {
  597.         return $this->postName;
  598.     }
  599.     /**
  600.      * @param mixed $instanceId
  601.      */
  602.     public function setInstanceId($instanceId)
  603.     {
  604.         $this->instanceId $instanceId;
  605.     }
  606.     /**
  607.      * @return mixed
  608.      */
  609.     public function getInstanceId()
  610.     {
  611.         return $this->instanceId;
  612.     }
  613.     /**
  614.      * @param mixed $supplierName
  615.      */
  616.     public function setSupplierName($supplierName)
  617.     {
  618.         $this->supplierName $supplierName;
  619.     }
  620.     /**
  621.      * @return mixed
  622.      */
  623.     public function getSupplierName()
  624.     {
  625.         return $this->supplierName;
  626.     }
  627.     /**
  628.      * @param mixed $distributorId
  629.      */
  630.     public function setDistributorId($distributorId)
  631.     {
  632.         $this->distributorId $distributorId;
  633.     }
  634.     /**
  635.      * @return mixed
  636.      */
  637.     public function getDistributorId()
  638.     {
  639.         return $this->distributorId;
  640.     }
  641.     /**
  642.      * @param mixed $customCategoryId
  643.      */
  644.     public function setCustomCategoryId($customCategoryId)
  645.     {
  646.         $this->customCategoryId $customCategoryId;
  647.     }
  648.     /**
  649.      * @return mixed
  650.      */
  651.     public function getCustomCategoryId()
  652.     {
  653.         return $this->customCategoryId;
  654.     }
  655.     /**
  656.      * @param mixed $productId
  657.      */
  658.     public function setProductId($productId)
  659.     {
  660.         $this->productId $productId;
  661.     }
  662.     /**
  663.      * @return mixed
  664.      */
  665.     public function getProductId()
  666.     {
  667.         return $this->productId;
  668.     }
  669.     /**
  670.      * @param mixed $userRole
  671.      */
  672.     public function setUserRole($userRole)
  673.     {
  674.         $this->userRole $userRole;
  675.     }
  676.     
  677.     /**
  678.      * @return mixed
  679.      */
  680.     public function getUserRole()
  681.     {
  682.         return $this->userRole;
  683.     }
  684.         
  685.     /**
  686.      * @param mixed $userId
  687.      */
  688.     public function setUserId($userId)
  689.     {
  690.         $this->userId $userId;
  691.     }
  692.         
  693.     /**
  694.      * @return mixed
  695.      */
  696.     public function getUserId()
  697.     {
  698.         return $this->userId;
  699.     }
  700.     
  701.     /**
  702.      * @param mixed $rating
  703.      */
  704.     public function setRating($rating)
  705.     {
  706.         $this->rating $rating;
  707.     }
  708.     
  709.     /**
  710.      * @return mixed
  711.      */
  712.     public function getRating()
  713.     {
  714.         return $this->rating;
  715.     }
  716.     
  717.     /**
  718.      * @param mixed $rating
  719.      */
  720.     public function setSupplier($supplier)
  721.     {
  722.         $this->supplier $supplier;
  723.     }
  724.     
  725.     /**
  726.      * @return mixed
  727.      */
  728.     public function getSupplier()
  729.     {
  730.         return $this->supplier;
  731.     }
  732.     
  733.     public function getCategoryIdNot()
  734.     {
  735.         return $this->categoryIdNot;
  736.     }
  737.     
  738.     public function setCategoryIdNot($categoryIdNot)
  739.     {
  740.         $this->categoryIdNot $categoryIdNot;
  741.         return $this;
  742.     }
  743.     
  744.     /**
  745.      * @param mixed $productIdNot
  746.      */
  747.     public function setProductIdNot($productIdNot)
  748.     {
  749.         $this->productIdNot $productIdNot;
  750.     }
  751.     
  752.     /**
  753.      * @return mixed
  754.      */
  755.     public function getProductIdNot()
  756.     {
  757.         return $this->productIdNot;
  758.     }
  759.     
  760.     public function getTagNot()
  761.     {
  762.         return $this->tagNot;
  763.     }
  764.     
  765.     public function setTagNot($tagNot)
  766.     {
  767.         $this->tagNot $tagNot;
  768.         return $this;
  769.     }
  770. }