diff --git a/Services/Helper/ShopwareArticleHelper.php b/Services/Helper/ShopwareArticleHelper.php index c510476..f4e9d92 100644 --- a/Services/Helper/ShopwareArticleHelper.php +++ b/Services/Helper/ShopwareArticleHelper.php @@ -145,10 +145,18 @@ public function setSimpleArticleValues(ShopwareArticle $entity, ValueArticle &$a $article->setLastStock(true); } - /** @var Price $price */ - $price = $detail->getPrices()->filter(function (Price $price) { - return $price->getCustomerGroup() === $this->customerGroup; - })->first(); + $prices = $detail->getPrices(); + foreach ($prices AS $detailPrice) { + $group = $detailPrice->getCustomerGroup(); + if ($group === $this->customerGroup) { + $price = $detailPrice; + break; + } + } + // if no price is found for the default customer group, use first found price + if (empty($price)) { + $price = $detail->getPrices()->first(); + } $price = Helper::convertPrice($price->getPrice(), $entity->getTax()->getTax(), $netInput); $article->setPrice($price); @@ -201,9 +209,18 @@ public function setVariantValues( $variant->setLastStock(true); } - $price = $detail->getPrices()->filter(function (Price $price) { - return $price->getCustomerGroup() === $this->customerGroup; - })->first(); + $prices = $detail->getPrices(); + foreach ($prices AS $detailPrice) { + $group = $detailPrice->getCustomerGroup(); + if ($group === $this->customerGroup) { + $price = $detailPrice; + break; + } + } + // if no price is found for the default customer group, use first found price + if (empty($price)) { + $price = $detail->getPrices()->first(); + } $options = []; @@ -1018,7 +1035,7 @@ public function getUnexportedArticles($force = false, $exportAll = true) if ( ! $force) { $articles = $articles->andWhere("(attributes.afterbuyId IS NULL OR attributes.afterbuyId = '') OR articles.changed >= :lastExport") - ->setParameters(array('lastExport' => $lastExport)); + ->setParameter('lastExport',$lastExport); } $articles = $articles->getQuery() @@ -1440,7 +1457,8 @@ private function associateVariantImage( ->from(ImageRule::class, 'rule') ->where('rule.mappingId = :mapping') ->andWhere('rule.optionId = :option') - ->setParameters(array('mapping' => $imageMapping->getId(), 'option' => $option->getId())) + ->setParameter('mapping', $imageMapping->getId()) + ->setParameter('option', $option->getId()) ->setMaxResults(1) ->getQuery(); diff --git a/Services/Helper/ShopwareOrderHelper.php b/Services/Helper/ShopwareOrderHelper.php index bc0e0cc..5289439 100644 --- a/Services/Helper/ShopwareOrderHelper.php +++ b/Services/Helper/ShopwareOrderHelper.php @@ -385,7 +385,7 @@ public function getUnexportedOrders(array $config) $minOrderDate = new DateTime($config["minOrderDate"]); $query->andWhere('orders.orderTime > :minOrderDate') - ->setParameters(array('minOrderDate' => $minOrderDate)); + ->setParameter('minOrderDate', $minOrderDate); } $orders = $query @@ -433,7 +433,7 @@ public function getNewFullfilledOrders() ->having('history.changeDate >= :lastExport') ->andHaving('history.paymentStatusId = 12') ->andHaving('history.orderStatusId = 2 OR history.orderStatusId = 7') - ->setParameters(array('lastExport' => $lastExport)) + ->setParameter('lastExport', $lastExport) ->getQuery() ->setMaxResults(145) ->getResult(); @@ -722,7 +722,7 @@ public function getPaymentStates() ->select('states') ->from(OrderStatus::class, 'states', 'states.name') ->where('states.group = :group') - ->setParameters(array('group' => 'payment')) + ->setParameter('group', 'payment') ->getQuery() ->getResult(); @@ -738,7 +738,7 @@ public function getShippingStates() ->select('states') ->from(OrderStatus::class, 'states', 'states.name') ->where('states.group = :group') - ->setParameters(array('group' => 'state')) + ->setParameter('group', 'state') ->getQuery() ->getResult();