示例#1
0
 /**
  * Initializes the catalog item.
  *
  * @param \Aimeos\MW\Tree\Node\Iface $node Tree node
  * @param \Aimeos\MShop\Catalog\Item\Iface[] $children List of children of the item
  * @param \Aimeos\MShop\Common\Lists\Item\Iface[] $listItems List of list items
  * @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items
  */
 public function __construct(\Aimeos\MW\Tree\Node\Iface $node, array $children = array(), array $listItems = array(), array $refItems = array())
 {
     parent::__construct('', array(), $listItems, $refItems);
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Catalog\\Item\\Iface', $children);
     $this->children = $children;
     $this->node = $node;
 }
示例#2
0
 /**
  * Initializes the site object.
  *
  * @param array $values Possible params to be set on initialization
  */
 public function __construct(array $values = array(), array $children = array())
 {
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Locale\\Item\\Site\\Iface', $children);
     parent::__construct('locale.site.', $values);
     $this->values = $values;
     $this->children = $children;
 }
示例#3
0
 /**
  * Initializes the object.
  *
  * @param string $url Initial url
  * @param string $method Initial method (e.g. post or get)
  * @param array $values Form parameters implementing \Aimeos\MW\Criteria\Attribute\Iface
  * @param boolean $external True if URL points to an external site, false if it stays on the same site
  */
 public function __construct($url = '', $method = '', array $values = array(), $external = true)
 {
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MW\\Criteria\\Attribute\\Iface', $values);
     $this->url = (string) $url;
     $this->external = (bool) $external;
     $this->method = (string) $method;
     $this->values = $values;
 }
示例#4
0
文件: SQL.php 项目: mvnp/aimeos-core
 /**
  * Initializes the object.
  *
  * @param string $operator The used combine operator
  * @param array $list List of expression objects
  */
 public function __construct($operator, array $list)
 {
     if (!isset(self::$operators[$operator])) {
         throw new \Aimeos\MW\Common\Exception(sprintf('Invalid operator "%1$s"', $operator));
     }
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MW\\Criteria\\Expression\\Iface', $list);
     $this->operator = $operator;
     $this->expressions = $list;
 }
示例#5
0
 /**
  * Initializes the basket object
  *
  * @param \Aimeos\MShop\Price\Item\Iface $price Default price of the basket (usually 0.00)
  * @param \Aimeos\MShop\Locale\Item\Iface $locale Locale item containing the site, language and currency
  * @param array $values Associative list of key/value pairs containing, e.g. the order or user ID
  * @param array $products List of ordered products implementing \Aimeos\MShop\Order\Item\Base\Product\Iface
  * @param array $addresses List of order addresses implementing \Aimeos\MShop\Order\Item\Base\Address\Iface
  * @param array $services List of order services implementing \Aimeos\MShop\Order\Item\Base\Service\Iface
  * @param array $coupons Associative list of coupon codes as keys and ordered products implementing \Aimeos\MShop\Order\Item\Base\Product\Iface as values
  */
 public function __construct(\Aimeos\MShop\Price\Item\Iface $price, \Aimeos\MShop\Locale\Item\Iface $locale, array $values = array(), array $products = array(), array $addresses = array(), array $services = array(), array $coupons = array())
 {
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Order\\Item\\Base\\Product\\Iface', $products);
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Order\\Item\\Base\\Address\\Iface', $addresses);
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Order\\Item\\Base\\Service\\Iface', $services);
     foreach ($coupons as $couponProducts) {
         \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Order\\Item\\Base\\Product\\Iface', $couponProducts);
     }
     $this->products = $products;
     $this->addresses = $addresses;
     $this->services = $services;
     $this->coupons = $coupons;
 }
示例#6
0
 /**
  * Sets the new list of attribute items for the product.
  *
  * @param array $attributes List of attribute items implementing \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface
  * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
  */
 public function setAttributes(array $attributes)
 {
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Order\\Item\\Base\\Product\\Attribute\\Iface', $attributes);
     $this->attributes = $attributes;
     $this->attributesMap = null;
     $this->setModified();
     return $this;
 }
示例#7
0
 /**
  * Sets a array of order base product items
  *
  * @param array Associative list of product items which must implement the \Aimeos\MShop\Order\Item\Base\Product\Iface
  * @return \Aimeos\MShop\Order\Item\Base\Product\Iface Order base product item for chaining method calls
  */
 public function setProducts(array $products)
 {
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Order\\Item\\Base\\Product\\Iface', $products);
     $this->products = $products;
     $this->setModified();
     return $this;
 }
示例#8
0
 /**
  * Rebuilds the index text for searching products or specified list of products.
  * This can be a long lasting operation.
  *
  * @param \Aimeos\MShop\Common\Item\Iface[] $items Associative list of product IDs and items implementing \Aimeos\MShop\Product\Item\Iface
  */
 public function rebuildIndex(array $items = array())
 {
     if (empty($items)) {
         return;
     }
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Product\\Item\\Iface', $items);
     $context = $this->getContext();
     $sites = $context->getLocale()->getSitePath();
     $siteid = $context->getLocale()->getSiteId();
     $langIds = $this->getLanguageIds($sites);
     $editor = $context->getEditor();
     $date = date('Y-m-d H:i:s');
     $dbm = $context->getDatabaseManager();
     $dbname = $this->getResourceName();
     $conn = $dbm->acquire($dbname);
     try {
         foreach ($items as $item) {
             $parentId = $item->getId();
             //  id is not $item->getId() for sub-products
             $listTypes = array();
             foreach ($item->getListItems('text') as $listItem) {
                 $listTypes[$listItem->getRefId()][] = $listItem->getType();
             }
             /** mshop/index/manager/text/standard/insert
              * Inserts a new text record into the product index database
              *
              * During the product index rebuild, texts related to a product
              * will be stored in the index for this product. All records
              * are deleted before the new ones are inserted.
              *
              * The SQL statement must be a string suitable for being used as
              * prepared statement. It must include question marks for binding
              * the values from the order item to the statement before they are
              * sent to the database server. The number of question marks must
              * be the same as the number of columns listed in the INSERT
              * statement. The order of the columns must correspond to the
              * order in the rebuildIndex() method, so the correct values are
              * bound to the columns.
              *
              * The SQL statement should conform to the ANSI standard to be
              * compatible with most relational database systems. This also
              * includes using double quotes for table and column names.
              *
              * @param string SQL statement for inserting records
              * @since 2014.03
              * @category Developer
              * @see mshop/index/manager/text/standard/cleanup
              * @see mshop/index/manager/text/standard/count
              * @see mshop/index/manager/text/standard/delete
              * @see mshop/index/manager/text/standard/insert
              * @see mshop/index/manager/text/standard/search
              * @see mshop/index/manager/text/standard/text
              */
             $stmt = $this->getCachedStatement($conn, 'mshop/index/manager/text/standard/insert');
             foreach ($item->getRefItems('text') as $refId => $refItem) {
                 if (!isset($listTypes[$refId])) {
                     $msg = sprintf('List type for text item with ID "%1$s" not available', $refId);
                     throw new \Aimeos\MShop\Catalog\Exception($msg);
                 }
                 foreach ($listTypes[$refId] as $listType) {
                     $this->saveText($stmt, $parentId, $siteid, $refId, $refItem->getLanguageId(), $listType, $refItem->getType(), 'product', $refItem->getContent(), $date, $editor);
                 }
             }
             $nameList = array();
             foreach ($item->getRefItems('text', 'name') as $refItem) {
                 $nameList[$refItem->getLanguageId()] = $refItem;
             }
             foreach ($langIds as $langId) {
                 if (!isset($nameList[$langId])) {
                     $this->saveText($stmt, $parentId, $siteid, null, $langId, 'default', 'name', 'product', $item->getLabel(), $date, $editor);
                 }
             }
         }
         $dbm->release($conn, $dbname);
     } catch (\Exception $e) {
         $dbm->release($conn, $dbname);
         throw $e;
     }
     $this->saveAttributeTexts($items);
     foreach ($this->getSubManagers() as $submanager) {
         $submanager->rebuildIndex($items);
     }
 }
示例#9
0
 /**
  * Rebuilds the index price for searching products or specified list of products.
  * This can be a long lasting operation.
  *
  * @param \Aimeos\MShop\Common\Item\Iface[] $items Associative list of product IDs and items implementing \Aimeos\MShop\Product\Item\Iface
  */
 public function rebuildIndex(array $items = array())
 {
     if (empty($items)) {
         return;
     }
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Product\\Item\\Iface', $items);
     $context = $this->getContext();
     $siteid = $context->getLocale()->getSiteId();
     $editor = $context->getEditor();
     $date = date('Y-m-d H:i:s');
     $dbm = $context->getDatabaseManager();
     $dbname = $this->getResourceName();
     $conn = $dbm->acquire($dbname);
     try {
         foreach ($items as $item) {
             $listTypes = array();
             foreach ($item->getListItems('price') as $listItem) {
                 $listTypes[$listItem->getRefId()][] = $listItem->getType();
             }
             /** mshop/index/manager/price/standard/insert
              * Inserts a new price record into the product index database
              *
              * During the product index rebuild, prices related to a product
              * will be stored in the index for this product. All records
              * are deleted before the new ones are inserted.
              *
              * The SQL statement must be a string suitable for being used as
              * prepared statement. It must include question marks for binding
              * the values from the order item to the statement before they are
              * sent to the database server. The number of question marks must
              * be the same as the number of columns listed in the INSERT
              * statement. The order of the columns must correspond to the
              * order in the rebuildIndex() method, so the correct values are
              * bound to the columns.
              *
              * The SQL statement should conform to the ANSI standard to be
              * compatible with most relational database systems. This also
              * includes using double quotes for table and column names.
              *
              * @param string SQL statement for inserting records
              * @since 2014.03
              * @category Developer
              * @see mshop/index/manager/price/standard/cleanup
              * @see mshop/index/manager/price/standard/delete
              * @see mshop/index/manager/price/standard/search
              * @see mshop/index/manager/price/standard/count
              */
             $stmt = $this->getCachedStatement($conn, 'mshop/index/manager/price/standard/insert');
             foreach ($item->getRefItems('price') as $refId => $refItem) {
                 if (!isset($listTypes[$refId])) {
                     $msg = sprintf('List type for price item with ID "%1$s" not available', $refId);
                     throw new \Aimeos\MShop\Index\Exception($msg);
                 }
                 foreach ($listTypes[$refId] as $listType) {
                     $stmt->bind(1, $item->getId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
                     $stmt->bind(2, $siteid, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
                     $stmt->bind(3, $refId, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
                     $stmt->bind(4, $refItem->getCurrencyId());
                     $stmt->bind(5, $listType);
                     $stmt->bind(6, $refItem->getType());
                     $stmt->bind(7, $refItem->getValue());
                     $stmt->bind(8, $refItem->getCosts());
                     $stmt->bind(9, $refItem->getRebate());
                     $stmt->bind(10, $refItem->getTaxRate());
                     $stmt->bind(11, $refItem->getQuantity(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
                     $stmt->bind(12, $date);
                     //mtime
                     $stmt->bind(13, $editor);
                     $stmt->bind(14, $date);
                     //ctime
                     try {
                         $stmt->execute()->finish();
                     } catch (\Aimeos\MW\DB\Exception $e) {
                     }
                     // Ignore duplicates
                 }
             }
         }
         $dbm->release($conn, $dbname);
     } catch (\Exception $e) {
         $dbm->release($conn, $dbname);
         throw $e;
     }
     foreach ($this->getSubManagers() as $submanager) {
         $submanager->rebuildIndex($items);
     }
 }
示例#10
0
 /**
  * Rebuilds the index price for searching products or specified list of products.
  * This can be a long lasting operation.
  *
  * @param \Aimeos\MShop\Common\Item\Iface[] $items Associative list of product IDs and items implementing \Aimeos\MShop\Product\Item\Iface
  */
 public function rebuildIndex(array $items = array())
 {
     if (empty($items)) {
         return;
     }
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Product\\Item\\Iface', $items);
     $context = $this->getContext();
     $dbm = $context->getDatabaseManager();
     $dbname = $this->getResourceName();
     $conn = $dbm->acquire($dbname);
     try {
         /** mshop/index/manager/price/standard/insert/mysql
          * Inserts a new price record into the product index database
          *
          * @see mshop/index/manager/price/standard/insert/ansi
          */
         /** mshop/index/manager/price/standard/insert/ansi
          * Inserts a new price record into the product index database
          *
          * During the product index rebuild, prices related to a product
          * will be stored in the index for this product. All records
          * are deleted before the new ones are inserted.
          *
          * The SQL statement must be a string suitable for being used as
          * prepared statement. It must include question marks for binding
          * the values from the order item to the statement before they are
          * sent to the database server. The number of question marks must
          * be the same as the number of columns listed in the INSERT
          * statement. The order of the columns must correspond to the
          * order in the rebuildIndex() method, so the correct values are
          * bound to the columns.
          *
          * The SQL statement should conform to the ANSI standard to be
          * compatible with most relational database systems. This also
          * includes using double quotes for table and column names.
          *
          * @param string SQL statement for inserting records
          * @since 2014.03
          * @category Developer
          * @see mshop/index/manager/price/standard/cleanup/ansi
          * @see mshop/index/manager/price/standard/delete/ansi
          * @see mshop/index/manager/price/standard/search/ansi
          * @see mshop/index/manager/price/standard/count/ansi
          */
         $stmt = $this->getCachedStatement($conn, 'mshop/index/manager/price/standard/insert');
         foreach ($items as $item) {
             $listTypes = array();
             foreach ($item->getListItems('price') as $listItem) {
                 $listTypes[$listItem->getRefId()][] = $listItem->getType();
             }
             $this->savePrices($stmt, $item, $listTypes);
         }
         $dbm->release($conn, $dbname);
     } catch (\Exception $e) {
         $dbm->release($conn, $dbname);
         throw $e;
     }
     foreach ($this->getSubManagers() as $submanager) {
         $submanager->rebuildIndex($items);
     }
 }
示例#11
0
 /**
  * Stores the sortation objects for sorting the result.
  *
  * @param \Aimeos\MW\Criteria\Expression\Sort\PHP[] $sortations List of objects implementing \Aimeos\MW\Criteria\Expression\Sort\Iface
  * @return \Aimeos\MW\Criteria\Iface Object instance for fluent interface
  */
 public function setSortations(array $sortations)
 {
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MW\\Criteria\\Expression\\Sort\\Iface', $sortations);
     $this->sortations = $sortations;
     return $this;
 }
示例#12
0
 /**
  * Rebuilds the index catalog for searching products or specified list of products.
  * This can be a long lasting operation.
  *
  * @param \Aimeos\MShop\Common\Item\Iface[] $items Associative list of product IDs and items implementing \Aimeos\MShop\Product\Item\Iface
  */
 public function rebuildIndex(array $items = array())
 {
     if (empty($items)) {
         return;
     }
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MShop\\Product\\Item\\Iface', $items);
     $listItems = $this->getListItems($items);
     $context = $this->getContext();
     $editor = $context->getEditor();
     $siteid = $context->getLocale()->getSiteId();
     $date = date('Y-m-d H:i:s');
     $dbm = $context->getDatabaseManager();
     $dbname = $this->getResourceName();
     $conn = $dbm->acquire($dbname);
     try {
         /** mshop/index/manager/catalog/standard/insert/mysql
          * Inserts a new catalog record into the product index database
          *
          * @see mshop/index/manager/catalog/standard/insert/ansi
          */
         /** mshop/index/manager/catalog/standard/insert/ansi
          * Inserts a new catalog record into the product index database
          *
          * During the product index rebuild, categories related to a
          * product will be stored in the index for this product. All
          * records are deleted before the new ones are inserted.
          *
          * The SQL statement must be a string suitable for being used as
          * prepared statement. It must include question marks for binding
          * the values from the order item to the statement before they are
          * sent to the database server. The number of question marks must
          * be the same as the number of columns listed in the INSERT
          * statement. The order of the columns must correspond to the
          * order in the rebuildIndex() method, so the correct values are
          * bound to the columns.
          *
          * The SQL statement should conform to the ANSI standard to be
          * compatible with most relational database systems. This also
          * includes using double quotes for table and column names.
          *
          * @param string SQL statement for inserting records
          * @since 2014.03
          * @category Developer
          * @see mshop/index/manager/catalog/standard/cleanup/ansi
          * @see mshop/index/manager/catalog/standard/delete/ansi
          * @see mshop/index/manager/catalog/standard/search/ansi
          * @see mshop/index/manager/catalog/standard/count/ansi
          */
         $stmt = $this->getCachedStatement($conn, 'mshop/index/manager/catalog/standard/insert');
         foreach ($items as $id => $item) {
             $parentId = $item->getId();
             // $id is not $item->getId() for sub-products
             if (!array_key_exists($parentId, $listItems)) {
                 continue;
             }
             foreach ((array) $listItems[$parentId] as $listItem) {
                 $stmt->bind(1, $parentId, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
                 $stmt->bind(2, $siteid, \Aimeos\MW\DB\Statement\Base::PARAM_INT);
                 $stmt->bind(3, $listItem->getParentId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
                 $stmt->bind(4, $listItem->getType());
                 $stmt->bind(5, $listItem->getPosition(), \Aimeos\MW\DB\Statement\Base::PARAM_INT);
                 $stmt->bind(6, $date);
                 //mtime
                 $stmt->bind(7, $editor);
                 $stmt->bind(8, $date);
                 //ctime
                 try {
                     $stmt->execute()->finish();
                 } catch (\Aimeos\MW\DB\Exception $e) {
                 }
                 // Ignore duplicates
             }
         }
         $dbm->release($conn, $dbname);
     } catch (\Exception $e) {
         $dbm->release($conn, $dbname);
         throw $e;
     }
     foreach ($this->getSubManagers() as $submanager) {
         $submanager->rebuildIndex($items);
     }
 }
示例#13
0
文件: Base.php 项目: mvnp/aimeos-core
 /**
  * Sets the new plugins for translating values.
  *
  * @param array $plugins Associative list of names and the plugin implementing \Aimeos\MW\Criteria\Plugin\Iface
  */
 protected function setPlugins(array $plugins)
 {
     \Aimeos\MW\Common\Base::checkClassList('\\Aimeos\\MW\\Criteria\\Plugin\\Iface', $plugins);
     $this->plugins = $plugins;
 }