From 78e04054da5c6c67089400dd703475c98c848fbe Mon Sep 17 00:00:00 2001 From: mandan2 Date: Mon, 11 Sep 2023 14:22:45 +0300 Subject: [PATCH] replaced getProducts to getCartProducts and product attribute array key --- subscription/Factory/CreateSubscriptionDataFactory.php | 2 +- subscription/Handler/SubscriptionCreationHandler.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/subscription/Factory/CreateSubscriptionDataFactory.php b/subscription/Factory/CreateSubscriptionDataFactory.php index 72278316a..109774f7b 100644 --- a/subscription/Factory/CreateSubscriptionDataFactory.php +++ b/subscription/Factory/CreateSubscriptionDataFactory.php @@ -68,7 +68,7 @@ public function build(Order $order, array $subscriptionProduct): SubscriptionDat //todo: will need to improve mollie module logic to have shop id or card it so that multishop doesn't break $molCustomer = $this->customerRepository->findOneBy(['email' => $customer->email]); - $combination = $this->combination->getById((int) $subscriptionProduct['product_attribute_id']); + $combination = $this->combination->getById((int) $subscriptionProduct['id_product_attribute']); $interval = $this->subscriptionInterval->getSubscriptionInterval($combination); $currency = $this->currencyAdapter->getById((int) $order->id_currency); diff --git a/subscription/Handler/SubscriptionCreationHandler.php b/subscription/Handler/SubscriptionCreationHandler.php index 87f5f8d6a..864c0479d 100644 --- a/subscription/Handler/SubscriptionCreationHandler.php +++ b/subscription/Handler/SubscriptionCreationHandler.php @@ -40,11 +40,11 @@ public function __construct( public function handle(Order $order, string $method) { - $products = $order->getProducts(); + $products = $order->getCartProducts(); $subscriptionProduct = []; foreach ($products as $product) { - if (!$this->subscriptionProductValidator->validate((int) $product['product_attribute_id'])) { + if (!$this->subscriptionProductValidator->validate((int) $product['id_product_attribute'])) { continue; } @@ -65,7 +65,7 @@ private function createRecurringOrdersProduct(array $product): MolRecurringOrder { $recurringOrdersProduct = new MolRecurringOrdersProduct(); $recurringOrdersProduct->id_product = $product['id_product']; - $recurringOrdersProduct->id_product_attribute = $product['product_attribute_id']; + $recurringOrdersProduct->id_product_attribute = $product['id_product_attribute']; $recurringOrdersProduct->quantity = $product['product_quantity']; $recurringOrdersProduct->unit_price = $product['unit_price_tax_excl']; $recurringOrdersProduct->add();