Skip to content

Commit

Permalink
Merge pull request #245 from Nosto/hotfix/2.4.7-order-confirmation-lo…
Browse files Browse the repository at this point in the history
…gging
  • Loading branch information
supercid committed Aug 11, 2020
2 parents 261e3f1 + 0281077 commit 314c3d5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Bootstrap.php
Expand Up @@ -86,7 +86,7 @@
class Shopware_Plugins_Frontend_NostoTagging_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
const PLATFORM_NAME = 'shopware';
const PLUGIN_VERSION = '2.4.6';
const PLUGIN_VERSION = '2.4.7';
const MENU_PARENT_ID = 23; // Configuration
const NEW_ENTITY_MANAGER_VERSION = '5.0.0';
const NEW_ATTRIBUTE_MANAGER_VERSION = '5.2.0';
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 2.4.7
- Fix sending invalid orders to Nosto by setting missing ISO code for customer country
- Remove excessive logging in order confirmation via API operations

## 2.4.6
- Fix an error where in some installations the plugin source path it is saved incorrectly

Expand Down
9 changes: 7 additions & 2 deletions Components/Customer.php
Expand Up @@ -86,15 +86,20 @@ public static function persistSession()
->Models()
->getRepository('\Shopware\CustomModels\Nosto\Customer\Customer')
->findOneBy(array('sessionId' => $sessionId));
$shouldPersist = false;
if (empty($customer)) {
$customer = new Customer();
$customer->setSessionId($sessionId);
$shouldPersist = true;
}
if ($nostoId !== $customer->getNostoId()) {
$customer->setNostoId($nostoId);
$shouldPersist = true;
}
if ($shouldPersist) {
Shopware()->Models()->persist($customer);
Shopware()->Models()->flush($customer);
}
Shopware()->Models()->persist($customer);
Shopware()->Models()->flush($customer);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Components/Model/Order/Buyer.php
Expand Up @@ -81,7 +81,7 @@ public function loadData(Customer $customer)
$this->setLastName($address->getLastname());
$this->setPostCode($address->getZipCode());
$this->setPhone($address->getPhone());
$this->setCountry($address->getCountry()->getName());
$this->setCountry($address->getCountry()->getIso());
}
} else {
/** @phan-suppress-next-line UndeclaredTypeInInlineVar */
Expand Down
13 changes: 10 additions & 3 deletions Components/Order/Confirmation.php
Expand Up @@ -39,6 +39,7 @@
use Shopware\Models\Attribute\Order as OrderAttribute;
use Shopware_Plugins_Frontend_NostoTagging_Components_Model_Order as NostoOrderModel;
use Shopware\Models\Order\Order as OrderModel;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;

/**
* Order confirmation component. Used to send order information to Nosto.
Expand All @@ -60,12 +61,14 @@ public function sendOrder(OrderModel $order)
{
try {
$shop = Shopware()->Shop();
} catch (\Exception $e) {
} catch (ServiceNotFoundException $e) {
$shop = $order->getShop();
// Shopware throws an exception if service does not exist.
// This would be the case when using Shopware API or cli
$shop = $order->getShop();
} catch (\Exception $e) {
/** @noinspection PhpUndefinedMethodInspection */
Shopware()->Plugins()->Frontend()->NostoTagging()->getLogger()->error($e->getMessage());
return;
}
if ($shop === null) {
return;
Expand All @@ -92,7 +95,11 @@ public function sendOrder(OrderModel $order)
$orderConfirmation->send($model, $customerId);
} catch (\Exception $e) {
/** @noinspection PhpUndefinedMethodInspection */
Shopware()->Plugins()->Frontend()->NostoTagging()->getLogger()->error($e->getMessage());
Shopware()->Plugins()->Frontend()->NostoTagging()->getLogger()->error(
sprintf("Nosto order update upsert failed. Message was: %s",
$e->getMessage()
)
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -4,7 +4,7 @@
"license": [
"BSD-3-Clause"
],
"version": "2.4.6",
"version": "2.4.7",
"require": {
"php": ">=5.4.0",
"nosto/php-sdk": "3.15.0"
Expand Down

0 comments on commit 314c3d5

Please sign in to comment.