/** * Saves the text items referenced indirectly by products * * @param \Aimeos\MW\DB\Statement\Iface $stmt Prepared SQL statement with place holders * @param \Aimeos\MShop\Common\Item\ListRef\Iface $item Item containing associated text items * @param array $listTypes Associative list of item ID / list type code pairs * @throws \Aimeos\MShop\Index\Exception If no list type for the item is available */ protected function savePrices(\Aimeos\MW\DB\Statement\Iface $stmt, \Aimeos\MShop\Common\Item\ListRef\Iface $item, array $listTypes) { $context = $this->getContext(); $siteid = $context->getLocale()->getSiteId(); $editor = $context->getEditor(); $date = date('Y-m-d H:i:s'); 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 } } }
/** * Saves the text items referenced indirectly by products * * @param \Aimeos\MW\DB\Statement\Iface $stmt Prepared SQL statement with place holders * @param \Aimeos\MShop\Common\Item\ListRef\Iface $item Item containing associated text items * @param array $listTypes Associative list of item ID / list type code pairs * @param array $prodIds Associative list of item ID / list of product IDs pairs * @throws \Aimeos\MShop\Index\Exception If no list type for the item is available */ protected function saveTexts(\Aimeos\MW\DB\Statement\Iface $stmt, \Aimeos\MShop\Common\Item\ListRef\Iface $item, array $listTypes, array $prodIds) { $context = $this->getContext(); $siteid = $context->getLocale()->getSiteId(); $editor = $context->getEditor(); $date = date('Y-m-d H:i:s'); foreach ($item->getRefItems('text') as $refId => $refItem) { if ($refItem->getContent() === '') { continue; } if (!isset($listTypes[$refId])) { $msg = sprintf('List type for text item with ID "%1$s" not available', $refId); throw new \Aimeos\MShop\Index\Exception($msg); } foreach ($listTypes[$refId] as $listType) { foreach ($prodIds[$item->getId()] as $productId) { $this->saveText($stmt, $productId, $siteid, $refId, $refItem->getLanguageId(), $listType, $refItem->getType(), $item->getResourceType(), $refItem->getContent(), $date, $editor); } } } }