vendor/pimcore/pimcore/bundles/EcommerceFrameworkBundle/IndexService/ProductList/DefaultMysql.php line 98

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Commercial License (PCL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  13.  */
  14. namespace Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList;
  15. use Monolog\Logger;
  16. use Pimcore\Bundle\EcommerceFrameworkBundle\CoreExtensions\ObjectData\IndexFieldSelection;
  17. use Pimcore\Bundle\EcommerceFrameworkBundle\Factory;
  18. use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Config\MysqlConfigInterface;
  19. use Pimcore\Bundle\EcommerceFrameworkBundle\Model\AbstractCategory;
  20. use Pimcore\Bundle\EcommerceFrameworkBundle\Model\IndexableInterface;
  21. /**
  22.  * Implementation of product list which works based on the product index of the online shop framework
  23.  */
  24. class DefaultMysql implements ProductListInterface
  25. {
  26.     /**
  27.      * @var null|IndexableInterface[]
  28.      */
  29.     protected $products null;
  30.     /**
  31.      * @var string
  32.      */
  33.     protected $tenantName;
  34.     /**
  35.      * @var MysqlConfigInterface
  36.      */
  37.     protected $tenantConfig;
  38.     /**
  39.      * @var null|int
  40.      */
  41.     protected $totalCount null;
  42.     /**
  43.      * @var string
  44.      */
  45.     protected $variantMode ProductListInterface::VARIANT_MODE_INCLUDE;
  46.     /**
  47.      * @var int
  48.      */
  49.     protected $limit;
  50.     /**
  51.      * @var int
  52.      */
  53.     protected $offset;
  54.     /**
  55.      * @var AbstractCategory
  56.      */
  57.     protected $category;
  58.     /**
  59.      * @var DefaultMysql\Dao|null
  60.      */
  61.     protected $resource;
  62.     /**
  63.      * @var bool
  64.      */
  65.     protected $inProductList true;
  66.     /**
  67.      * @var Logger
  68.      */
  69.     protected $logger;
  70.     public function __construct(MysqlConfigInterface $tenantConfig)
  71.     {
  72.         $this->tenantName $tenantConfig->getTenantName();
  73.         $this->tenantConfig $tenantConfig;
  74.         $this->logger \Pimcore::getContainer()->get('monolog.logger.pimcore_ecommerce_sql');
  75.         $this->resource = new DefaultMysql\Dao($this$this->logger);
  76.     }
  77.     /** @inheritDoc */
  78.     public function getProducts()
  79.     {
  80.         if ($this->products === null) {
  81.             $this->load();
  82.         }
  83.         return $this->products;
  84.     }
  85.     /**
  86.      * @var array
  87.      */
  88.     protected $conditions = [];
  89.     /**
  90.      * @var array<string[]>
  91.      */
  92.     protected $relationConditions = [];
  93.     /**
  94.      * @var string[][]
  95.      */
  96.     protected $queryConditions = [];
  97.     /**
  98.      * @var float|null
  99.      */
  100.     protected $conditionPriceFrom null;
  101.     /**
  102.      * @var float|null
  103.      */
  104.     protected $conditionPriceTo null;
  105.     /**
  106.      * @param array|string $condition
  107.      * @param string $fieldname
  108.      */
  109.     public function addCondition($condition$fieldname '')
  110.     {
  111.         $this->products null;
  112.         $this->conditions[$fieldname][] = $condition;
  113.     }
  114.     public function resetCondition($fieldname)
  115.     {
  116.         $this->products null;
  117.         unset($this->conditions[$fieldname]);
  118.     }
  119.     /**
  120.      * @param string $fieldname
  121.      * @param string $condition
  122.      */
  123.     public function addRelationCondition($fieldname$condition)
  124.     {
  125.         $this->products null;
  126.         $this->relationConditions[$fieldname][] = '`fieldname` = ' $this->quote($fieldname) . ' AND '  $condition;
  127.     }
  128.     /**
  129.      * resets all conditions of product list
  130.      */
  131.     public function resetConditions()
  132.     {
  133.         $this->conditions = [];
  134.         $this->relationConditions = [];
  135.         $this->queryConditions = [];
  136.         $this->conditionPriceFrom null;
  137.         $this->conditionPriceTo null;
  138.         $this->products null;
  139.     }
  140.     /**
  141.      * Adds query condition to product list for fulltext search
  142.      * Fieldname is optional but highly recommended - needed for resetting condition based on fieldname
  143.      * and exclude functionality in group by results
  144.      *
  145.      * @param string $condition
  146.      * @param string $fieldname
  147.      */
  148.     public function addQueryCondition($condition$fieldname '')
  149.     {
  150.         $this->products null;
  151.         $this->queryConditions[$fieldname][] = $condition;
  152.     }
  153.     /**
  154.      * Reset query condition for fieldname
  155.      *
  156.      * @param string $fieldname
  157.      */
  158.     public function resetQueryCondition($fieldname)
  159.     {
  160.         $this->products null;
  161.         unset($this->queryConditions[$fieldname]);
  162.     }
  163.     /**
  164.      * @param null|float $from
  165.      * @param null|float $to
  166.      */
  167.     public function addPriceCondition($from null$to null)
  168.     {
  169.         $this->products null;
  170.         $this->conditionPriceFrom $from;
  171.         $this->conditionPriceTo $to;
  172.     }
  173.     /**
  174.      * @param bool $inProductList
  175.      */
  176.     public function setInProductList($inProductList)
  177.     {
  178.         $this->products null;
  179.         $this->inProductList $inProductList;
  180.     }
  181.     /**
  182.      * @return bool
  183.      */
  184.     public function getInProductList()
  185.     {
  186.         return $this->inProductList;
  187.     }
  188.     protected $order;
  189.     /**
  190.      * @var string | array
  191.      */
  192.     protected $orderKey;
  193.     protected $orderByPrice false;
  194.     public function setOrder($order)
  195.     {
  196.         $this->products null;
  197.         $this->order $order;
  198.     }
  199.     public function getOrder()
  200.     {
  201.         return $this->order;
  202.     }
  203.     /**
  204.      * @param string|array $orderKey either single field name, or array of field names or array of arrays (field name, direction)
  205.      */
  206.     public function setOrderKey($orderKey)
  207.     {
  208.         $this->products null;
  209.         if ($orderKey == ProductListInterface::ORDERKEY_PRICE) {
  210.             $this->orderByPrice true;
  211.         } else {
  212.             $this->orderByPrice false;
  213.         }
  214.         $this->orderKey $orderKey;
  215.     }
  216.     public function getOrderKey()
  217.     {
  218.         return $this->orderKey;
  219.     }
  220.     public function setLimit($limit)
  221.     {
  222.         if ($this->limit != $limit) {
  223.             $this->products null;
  224.         }
  225.         $this->limit $limit;
  226.     }
  227.     public function getLimit()
  228.     {
  229.         return $this->limit;
  230.     }
  231.     public function setOffset($offset)
  232.     {
  233.         if ($this->offset != $offset) {
  234.             $this->products null;
  235.         }
  236.         $this->offset $offset;
  237.     }
  238.     public function getOffset()
  239.     {
  240.         return $this->offset;
  241.     }
  242.     public function setCategory(AbstractCategory $category)
  243.     {
  244.         $this->products null;
  245.         $this->category $category;
  246.     }
  247.     public function getCategory()
  248.     {
  249.         return $this->category;
  250.     }
  251.     public function setVariantMode($variantMode)
  252.     {
  253.         $this->products null;
  254.         $this->variantMode $variantMode;
  255.     }
  256.     public function getVariantMode()
  257.     {
  258.         return $this->variantMode;
  259.     }
  260.     public function load()
  261.     {
  262.         $objectRaws = [];
  263.         //First case: no price filtering and no price sorting
  264.         if (!$this->orderByPrice && $this->conditionPriceFrom === null && $this->conditionPriceTo === null) {
  265.             $objectRaws $this->loadWithoutPriceFilterWithoutPriceSorting();
  266.         }
  267.         //Second case: no price filtering but price sorting
  268.         elseif ($this->orderByPrice && $this->conditionPriceFrom === null && $this->conditionPriceTo === null) {
  269.             $objectRaws $this->loadWithoutPriceFilterWithPriceSorting();
  270.         }
  271.         //Third case: price filtering but no price sorting
  272.         elseif (!$this->orderByPrice && ($this->conditionPriceFrom !== null || $this->conditionPriceTo !== null)) {
  273.             $objectRaws $this->loadWithPriceFilterWithoutPriceSorting();
  274.         }
  275.         //Forth case: price filtering and price sorting
  276.         elseif ($this->orderByPrice && ($this->conditionPriceFrom !== null || $this->conditionPriceTo !== null)) {
  277.             $objectRaws $this->loadWithPriceFilterWithPriceSorting();
  278.         }
  279.         $this->products = [];
  280.         foreach ($objectRaws as $raw) {
  281.             $product $this->loadElementById($raw['o_id']);
  282.             if ($product) {
  283.                 $this->products[] = $product;
  284.             }
  285.         }
  286.         return $this->products;
  287.     }
  288.     /**
  289.      * First case: no price filtering and no price sorting
  290.      *
  291.      * @return array
  292.      */
  293.     protected function loadWithoutPriceFilterWithoutPriceSorting()
  294.     {
  295.         $objectRaws $this->resource->load($this->buildQueryFromConditions(), $this->buildOrderBy(), $this->getLimit(), $this->getOffset());
  296.         $this->totalCount $this->resource->getLastRecordCount();
  297.         return $objectRaws;
  298.     }
  299.     /**
  300.      * Second case: no price filtering but price sorting
  301.      *
  302.      * @return array
  303.      *
  304.      * @throws \Exception
  305.      *
  306.      * @todo Not implemented yet
  307.      */
  308.     protected function loadWithoutPriceFilterWithPriceSorting()
  309.     {
  310.         $objectRaws $this->resource->load($this->buildQueryFromConditions());
  311.         $this->totalCount $this->resource->getLastRecordCount();
  312.         $priceSystemArrays = [];
  313.         foreach ($objectRaws as $raw) {
  314.             $priceSystemArrays[$raw['priceSystemName']][] = $raw['o_id'];
  315.         }
  316.         if (count($priceSystemArrays) == 1) {
  317.             $priceSystemName key($priceSystemArrays);
  318.             $priceSystem Factory::getInstance()->getPriceSystem($priceSystemName);
  319.             $objectRaws $priceSystem->filterProductIds($priceSystemArrays[$priceSystemName], nullnull$this->order$this->getOffset(), $this->getLimit());
  320.         } elseif (count($priceSystemArrays) == 0) {
  321.             //nothing to do
  322.         } else {
  323.             throw new \Exception('Not implemented yet - multiple pricing systems are not supported yet');
  324.         }
  325.         return $objectRaws;
  326.     }
  327.     /**
  328.      * Third case: price filtering but no price sorting
  329.      *
  330.      * @return array
  331.      *
  332.      * @throws \Exception
  333.      *
  334.      * @todo Not implemented yet
  335.      */
  336.     protected function loadWithPriceFilterWithoutPriceSorting()
  337.     {
  338.         //check number of price systems
  339.         //set $this->totalCount
  340.         throw new \Exception('Not implemented yet');
  341.     }
  342.     /**
  343.      * Forth case: price filtering and price sorting
  344.      *
  345.      * @return array
  346.      *
  347.      * @throws \Exception
  348.      *
  349.      * @todo Not implemented yet
  350.      */
  351.     protected function loadWithPriceFilterWithPriceSorting()
  352.     {
  353.         //check number of price systems
  354.         //set $this->totalCount
  355.         throw new \Exception('Not implemented yet');
  356.     }
  357.     /**
  358.      * loads element by id
  359.      *
  360.      * @param int $elementId
  361.      *
  362.      * @return IndexableInterface|null
  363.      */
  364.     protected function loadElementById($elementId)
  365.     {
  366.         return $this->getCurrentTenantConfig()->getObjectMockupById($elementId);
  367.     }
  368.     /**
  369.      * prepares all group by values for given field names and cache them in local variable
  370.      * considers both - normal values and relation values
  371.      *
  372.      * @param string $fieldname
  373.      *
  374.      * @return void
  375.      */
  376.     public function prepareGroupByValues($fieldname$countValues false$fieldnameShouldBeExcluded true)
  377.     {
  378.         // not supported with mysql tables
  379.     }
  380.     /**
  381.      * resets all set prepared group by values
  382.      *
  383.      * @return void
  384.      */
  385.     public function resetPreparedGroupByValues()
  386.     {
  387.         // not supported with mysql tables
  388.     }
  389.     /**
  390.      * prepares all group by values for given field names and cache them in local variable
  391.      * considers both - normal values and relation values
  392.      *
  393.      * @param string $fieldname
  394.      *
  395.      * @return void
  396.      */
  397.     public function prepareGroupByRelationValues($fieldname$countValues false$fieldnameShouldBeExcluded true)
  398.     {
  399.         // not supported with mysql tables
  400.     }
  401.     /**
  402.      * prepares all group by values for given field names and cache them in local variable
  403.      * considers both - normal values and relation values
  404.      *
  405.      * @param string $fieldname
  406.      *
  407.      * @return void
  408.      */
  409.     public function prepareGroupBySystemValues($fieldname$countValues false$fieldnameShouldBeExcluded true)
  410.     {
  411.         // not supported with mysql tables
  412.     }
  413.     /**
  414.      * loads group by values based on relation fieldname either from local variable if prepared or directly from product index
  415.      *
  416.      * @param string $fieldname
  417.      * @param bool $countValues
  418.      * @param bool $fieldnameShouldBeExcluded => set to false for and-conditions
  419.      *
  420.      * @return array
  421.      *
  422.      * @throws \Exception
  423.      */
  424.     public function getGroupBySystemValues($fieldname$countValues false$fieldnameShouldBeExcluded true)
  425.     {
  426.         // not supported with mysql tables
  427.         return [];
  428.     }
  429.     /**
  430.      * @param string $fieldname
  431.      * @param bool $countValues
  432.      * @param bool $fieldnameShouldBeExcluded => set to false for and-conditions
  433.      *
  434.      * @return array
  435.      *
  436.      * @throws \Exception
  437.      */
  438.     public function getGroupByValues($fieldname$countValues false$fieldnameShouldBeExcluded true)
  439.     {
  440.         $excludedFieldName $fieldname;
  441.         if (!$fieldnameShouldBeExcluded) {
  442.             $excludedFieldName null;
  443.         }
  444.         if ($this->conditionPriceFrom === null && $this->conditionPriceTo === null) {
  445.             return $this->resource->loadGroupByValues($fieldname$this->buildQueryFromConditions(false$excludedFieldName$this->getVariantMode()), $countValues);
  446.         } else {
  447.             throw new \Exception('Not supported yet');
  448.         }
  449.     }
  450.     /**
  451.      * @param string $fieldname
  452.      * @param bool $countValues
  453.      * @param bool $fieldnameShouldBeExcluded => set to false for and-conditions
  454.      *
  455.      * @return array
  456.      *
  457.      * @throws \Exception
  458.      */
  459.     public function getGroupByRelationValues($fieldname$countValues false$fieldnameShouldBeExcluded true)
  460.     {
  461.         $excludedFieldName $fieldname;
  462.         if (!$fieldnameShouldBeExcluded) {
  463.             $excludedFieldName null;
  464.         }
  465.         if ($this->conditionPriceFrom === null && $this->conditionPriceTo === null) {
  466.             return $this->resource->loadGroupByRelationValues($fieldname$this->buildQueryFromConditions(false$excludedFieldName), $countValues);
  467.         } else {
  468.             throw new \Exception('Not supported yet');
  469.         }
  470.     }
  471.     protected function buildQueryFromConditions($excludeConditions false$excludedFieldname null$variantMode null)
  472.     {
  473.         if ($variantMode == null) {
  474.             $variantMode $this->getVariantMode();
  475.         }
  476.         $preCondition 'active = 1 AND o_virtualProductActive = 1';
  477.         if ($this->inProductList) {
  478.             $preCondition .= ' AND inProductList = 1';
  479.         }
  480.         $tenantCondition $this->getCurrentTenantConfig()->getCondition();
  481.         if ($tenantCondition) {
  482.             $preCondition .= ' AND ' $tenantCondition;
  483.         }
  484.         if ($this->getCategory()) {
  485.             $preCondition .= " AND parentCategoryIds LIKE '%," $this->getCategory()->getId() . ",%'";
  486.         }
  487.         $condition $preCondition;
  488.         //variant handling and userspecific conditions
  489.         switch ($variantMode) {
  490.             case ProductListInterface::VARIANT_MODE_INCLUDE_PARENT_OBJECT:
  491.                 //make sure, that only variant objects are considered
  492.                 $condition .= ' AND a.o_id != o_virtualProductId ';
  493.                 break;
  494.             case ProductListInterface::VARIANT_MODE_HIDE:
  495.                 $condition .= " AND o_type != 'variant'";
  496.                 break;
  497.             case ProductListInterface::VARIANT_MODE_VARIANTS_ONLY:
  498.                 $condition .= " AND o_type = 'variant'";
  499.                 break;
  500.         }
  501.         if (!$excludeConditions) {
  502.             $userspecific $this->buildUserspecificConditions($excludedFieldname);
  503.             if ($userspecific) {
  504.                 $condition .= ' AND ' $userspecific;
  505.             }
  506.         }
  507.         if ($this->queryConditions) {
  508.             $searchstring '';
  509.             foreach ($this->queryConditions as $queryConditionPartArray) {
  510.                 foreach ($queryConditionPartArray as $queryConditionPart) {
  511.                     //check if there are any mysql special characters in query condition - if so, then quote condition
  512.                     if (str_replace(['+''-''<''>''('')''~''*'], ''$queryConditionPart) != $queryConditionPart) {
  513.                         $searchstring .= '+"' $queryConditionPart '" ';
  514.                     } else {
  515.                         $searchstring .= '+' $queryConditionPart '* ';
  516.                     }
  517.                 }
  518.             }
  519.             $condition .= ' AND ' $this->resource->buildFulltextSearchWhere($this->tenantConfig->getSearchAttributes(), $searchstring);
  520.         }
  521.         $this->logger->info('Total Condition: ' $condition);
  522.         return $condition;
  523.     }
  524.     protected function buildUserspecificConditions($excludedFieldname null)
  525.     {
  526.         $condition '';
  527.         foreach ($this->relationConditions as $fieldname => $condArray) {
  528.             if ($fieldname !== $excludedFieldname) {
  529.                 foreach ($condArray as $cond) {
  530.                     if ($condition) {
  531.                         $condition .= ' AND ';
  532.                     }
  533.                     $condition .= 'a.o_id IN (SELECT DISTINCT src FROM ' $this->getCurrentTenantConfig()->getRelationTablename() . ' WHERE ' $cond ')';
  534.                 }
  535.             }
  536.         }
  537.         foreach ($this->conditions as $fieldname => $condArray) {
  538.             if ($fieldname !== $excludedFieldname) {
  539.                 foreach ($condArray as $cond) {
  540.                     if ($condition) {
  541.                         $condition .= ' AND ';
  542.                     }
  543.                     $condition .= is_array($cond)
  544.                         ? sprintf(' ( %1$s IN (%2$s) )'$fieldnameimplode(','array_map(function ($value) {
  545.                             return $this->quote($value);
  546.                         }, $cond)))
  547.                         : '(' $cond ')'
  548.                     ;
  549.                 }
  550.             }
  551.         }
  552.         $this->logger->info('User specific Condition Part: ' $condition);
  553.         return $condition;
  554.     }
  555.     protected function buildOrderBy()
  556.     {
  557.         if (!empty($this->orderKey) && $this->orderKey !== ProductListInterface::ORDERKEY_PRICE) {
  558.             $orderKeys $this->orderKey;
  559.             if (!is_array($orderKeys)) {
  560.                 $orderKeys = [$orderKeys];
  561.             }
  562.             // add sorting for primary id to prevent mysql paging problem...
  563.             $orderKeys[] = 'a.o_id';
  564.             $directionOrderKeys = [];
  565.             foreach ($orderKeys as $key) {
  566.                 if (is_array($key)) {
  567.                     $directionOrderKeys[] = $key;
  568.                 } else {
  569.                     $directionOrderKeys[] = [$key$this->order];
  570.                 }
  571.             }
  572.             $orderByStringArray = [];
  573.             foreach ($directionOrderKeys as $keyDirection) {
  574.                 $key $keyDirection[0];
  575.                 if ($key instanceof IndexFieldSelection) {
  576.                     $key $key->getField();
  577.                 }
  578.                 $direction $keyDirection[1];
  579.                 if ($this->getVariantMode() == ProductListInterface::VARIANT_MODE_INCLUDE_PARENT_OBJECT) {
  580.                     if (strtoupper($this->order) == 'DESC') {
  581.                         $orderByStringArray[] = 'max(' $key ') ' $direction;
  582.                     } else {
  583.                         $orderByStringArray[] = 'min(' $key ') ' $direction;
  584.                     }
  585.                 } else {
  586.                     $orderByStringArray[] = $key ' ' $direction;
  587.                 }
  588.             }
  589.             return implode(','$orderByStringArray);
  590.         }
  591.         return null;
  592.     }
  593.     public function quote($value)
  594.     {
  595.         return $this->resource->quote($value);
  596.     }
  597.     /**
  598.      * @return MysqlConfigInterface
  599.      */
  600.     public function getCurrentTenantConfig()
  601.     {
  602.         return $this->tenantConfig;
  603.     }
  604.     /**
  605.      * returns order by statement for simularity calculations based on given fields and object ids
  606.      * returns cosine simularity calculation
  607.      *
  608.      * @param array $fields
  609.      * @param int $objectId
  610.      *
  611.      * @return string
  612.      */
  613.     public function buildSimularityOrderBy($fields$objectId)
  614.     {
  615.         return $this->resource->buildSimularityOrderBy($fields$objectId);
  616.     }
  617.     /**
  618.      * returns where statement for fulltext search index
  619.      *
  620.      * @param array $fields
  621.      * @param string $searchstring
  622.      *
  623.      * @return string
  624.      */
  625.     public function buildFulltextSearchWhere($fields$searchstring)
  626.     {
  627.         return $this->resource->buildFulltextSearchWhere($fields$searchstring);
  628.     }
  629.     /**
  630.      *  -----------------------------------------------------------------------------------------
  631.      *   Methods for Iterator
  632.      *  -----------------------------------------------------------------------------------------
  633.      */
  634.     /**
  635.      * @return int
  636.      */
  637.     #[\ReturnTypeWillChange]
  638.     public function count()// : int
  639.     {
  640.         if ($this->totalCount === null) {
  641.             $this->totalCount $this->resource->getCount($this->buildQueryFromConditions());
  642.         }
  643.         return $this->totalCount;
  644.     }
  645.     /**
  646.      * @return IndexableInterface|false
  647.      */
  648.     #[\ReturnTypeWillChange]
  649.     public function current()// : IndexableInterface|false
  650.     {
  651.         $this->getProducts();
  652.         return current($this->products);
  653.     }
  654.     /**
  655.      * Returns an collection of items for a page.
  656.      *
  657.      * @param  int $offset Page offset
  658.      * @param  int $itemCountPerPage Number of items per page
  659.      *
  660.      * @return array
  661.      */
  662.     public function getItems($offset$itemCountPerPage)
  663.     {
  664.         $this->setOffset($offset);
  665.         $this->setLimit($itemCountPerPage);
  666.         return $this->getProducts();
  667.     }
  668.     /**
  669.      * @return int|null
  670.      */
  671.     #[\ReturnTypeWillChange]
  672.     public function key()// : int|null
  673.     {
  674.         $this->getProducts();
  675.         return key($this->products);
  676.     }
  677.     /**
  678.      * @return void
  679.      */
  680.     #[\ReturnTypeWillChange]
  681.     public function next()// : void
  682.     {
  683.         $this->getProducts();
  684.         next($this->products);
  685.     }
  686.     /**
  687.      * @return void
  688.      */
  689.     #[\ReturnTypeWillChange]
  690.     public function rewind()// : void
  691.     {
  692.         $this->getProducts();
  693.         reset($this->products);
  694.     }
  695.     /**
  696.      * @return bool
  697.      */
  698.     #[\ReturnTypeWillChange]
  699.     public function valid()// : bool
  700.     {
  701.         return $this->current() !== false;
  702.     }
  703.     /**
  704.      * @return array
  705.      *
  706.      * @internal
  707.      */
  708.     public function __sleep()
  709.     {
  710.         $vars get_object_vars($this);
  711.         unset($vars['resource']);
  712.         unset($vars['products']);
  713.         return array_keys($vars);
  714.     }
  715.     /**
  716.      * @internal
  717.      */
  718.     public function __wakeup()
  719.     {
  720.         if (empty($this->resource)) {
  721.             $this->logger \Pimcore::getContainer()->get('monolog.logger.pimcore_ecommerce_sql');
  722.             $this->resource = new DefaultMysql\Dao($this$this->logger);
  723.         }
  724.     }
  725.     /**
  726.      * this is needed for ZF1 Paginator
  727.      *
  728.      * @return string
  729.      */
  730.     public function getCacheIdentifier()
  731.     {
  732.         return uniqid();
  733.     }
  734. }