Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2.6.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoffer Lindqvist committed Oct 28, 2015
2 parents 6584828 + 1a5c315 commit 4bf97fa
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 61 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ Open Software License ("OSL") v3.0

## Changelog

### 2.6.7
* Ignore order status in tagging and API calls if they are not set properly
* Ignore empty string values for order buyer information in tagging and API calls

### 2.6.6
* Fix account removal for self-signup accounts through the iframe
* Fix uncaught "InvalidArgumentException" exception when order status is missing
Expand Down
34 changes: 20 additions & 14 deletions app/code/community/Nosto/Tagging/Model/Export/Collection/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ public function getJson()
$data = array(
'order_number' => $item->getOrderNumber(),
'external_order_ref' => $item->getExternalOrderRef(),
'order_status_code' => $item->getOrderStatus()->getCode(),
'order_status_label' => $item->getOrderStatus()->getLabel(),
'order_statuses' => array(),
'created_at' => Nosto::helper('date')->format($item->getCreatedDate()),
'buyer' => array(),
'payment_provider' => $item->getPaymentProvider(),
'purchased_items' => array(),
);
if ($item->getOrderStatus()) {
$data['order_status_code'] = $item->getOrderStatus()->getCode();
$data['order_status_label'] = $item->getOrderStatus()->getLabel();
}
foreach ($item->getPurchasedItems() as $orderItem) {
$data['purchased_items'][] = array(
'product_id' => $orderItem->getProductId(),
Expand All @@ -59,20 +61,24 @@ public function getJson()
);
}
foreach ($item->getOrderStatuses() as $status) {
if (!isset($data['order_statuses'][$status->getCode()])) {
$data['order_statuses'][$status->getCode()] = array();
if ($status->getCreatedAt()) {
if (!isset($data['order_statuses'][$status->getCode()])) {
$data['order_statuses'][$status->getCode()] = array();
}
$data['order_statuses'][$status->getCode()][] =
date('Y-m-d\TH:i:s\Z', strtotime($status->getCreatedAt()));
}
$data['order_statuses'][$status->getCode()][] =
date('Y-m-d\TH:i:s\Z', strtotime($status->getCreatedAt()));
}
if ($item->getBuyerInfo()->getFirstName()) {
$data['buyer']['first_name'] = $item->getBuyerInfo()->getFirstName();
}
if ($item->getBuyerInfo()->getLastName()) {
$data['buyer']['last_name'] = $item->getBuyerInfo()->getLastName();
}
if ($item->getBuyerInfo()->getEmail()) {
$data['buyer']['email'] = $item->getBuyerInfo()->getEmail();
if ($item->getBuyerInfo()) {
if ($item->getBuyerInfo()->getFirstName()) {
$data['buyer']['first_name'] = $item->getBuyerInfo()->getFirstName();
}
if ($item->getBuyerInfo()->getLastName()) {
$data['buyer']['last_name'] = $item->getBuyerInfo()->getLastName();
}
if ($item->getBuyerInfo()->getEmail()) {
$data['buyer']['email'] = $item->getBuyerInfo()->getEmail();
}
}

$array[] = $data;
Expand Down
32 changes: 18 additions & 14 deletions app/code/community/Nosto/Tagging/Model/Meta/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,30 @@ public function loadData(Mage_Sales_Model_Order $order)
$this->_createdDate = $order->getCreatedAt();
$this->_paymentProvider = $order->getPayment()->getMethod();

$this->_orderStatus = Mage::getModel(
'nosto_tagging/meta_order_status',
array(
'code' => $order->getStatus(),
'label' => $order->getStatusLabel()
)
);

foreach ($order->getAllStatusHistory() as $item) {
/** @var Mage_Sales_Model_Order_Status_History $item */
$this->_orderStatuses[] = Mage::getModel(
if ($order->getStatus()) {
$this->_orderStatus = Mage::getModel(
'nosto_tagging/meta_order_status',
array(
'code' => $item->getStatus(),
'label' => $item->getStatusLabel(),
'createdAt' => $item->getCreatedAt()
'code' => $order->getStatus(),
'label' => $order->getStatusLabel()
)
);
}

foreach ($order->getAllStatusHistory() as $item) {
/** @var Mage_Sales_Model_Order_Status_History $item */
if ($item->getStatus()) {
$this->_orderStatuses[] = Mage::getModel(
'nosto_tagging/meta_order_status',
array(
'code' => $item->getStatus(),
'label' => $item->getStatusLabel(),
'createdAt' => $item->getCreatedAt()
)
);
}
}

$this->_buyer = Mage::getModel(
'nosto_tagging/meta_order_buyer',
array(
Expand Down
18 changes: 9 additions & 9 deletions app/code/community/Nosto/Tagging/Model/Meta/Order/Buyer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,24 @@ class Nosto_Tagging_Model_Meta_Order_Buyer extends Mage_Core_Model_Abstract impl
public function __construct(array $args)
{
if (isset($args['firstName'])) {
if (!is_string($args['firstName']) || empty($args['firstName'])) {
throw new InvalidArgumentException(sprintf('%s.firstName must be a non-empty string value.', __CLASS__));
if (!is_string($args['firstName'])) {
throw new InvalidArgumentException(sprintf('%s.firstName must be a string value.', __CLASS__));
}
}
if (isset($args['lastName'])) {
if (!is_string($args['lastName']) || empty($args['lastName'])) {
throw new InvalidArgumentException(sprintf('%s.lastName must be a non-empty string value.', __CLASS__));
if (!is_string($args['lastName'])) {
throw new InvalidArgumentException(sprintf('%s.lastName must be a string value.', __CLASS__));
}
}
if (isset($args['email'])) {
if (!is_string($args['email']) || empty($args['email'])) {
throw new InvalidArgumentException(sprintf('%s.email must be a non-empty string value.', __CLASS__));
if (!is_string($args['email'])) {
throw new InvalidArgumentException(sprintf('%s.email must be a string value.', __CLASS__));
}
}

$this->_firstName = isset($args['firstName']) ? $args['firstName'] : null;
$this->_lastName = isset($args['lastName']) ? $args['lastName'] : null;
$this->_email = isset($args['email']) ? $args['email'] : null;
$this->_firstName = !empty($args['firstName']) ? $args['firstName'] : null;
$this->_lastName = !empty($args['lastName']) ? $args['lastName'] : null;
$this->_email = !empty($args['email']) ? $args['email'] : null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/code/community/Nosto/Tagging/Model/Meta/Order/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function __construct(array $args)
throw new InvalidArgumentException(sprintf('%s.code must be a non-empty string value.', __CLASS__));
}
if (isset($args['label'])) {
if (!is_string($args['label']) || empty($args['label'])) {
throw new InvalidArgumentException(sprintf('%s.label must be a non-empty string value.', __CLASS__));
if (!is_string($args['label'])) {
throw new InvalidArgumentException(sprintf('%s.label must be a string value.', __CLASS__));
}
}
if (isset($args['createdAt'])) {
Expand All @@ -77,7 +77,7 @@ public function __construct(array $args)
}

$this->_code = $args['code'];
$this->_label = isset($args['label']) ? $args['label'] : $args['code'];
$this->_label = !empty($args['label']) ? $args['label'] : $args['code'];
$this->_createdAt = isset($args['createdAt']) ? $args['createdAt'] : null;
}

Expand Down
24 changes: 14 additions & 10 deletions app/code/community/Nosto/Tagging/Model/Service/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ protected function getOrderAsJson(Nosto_Tagging_Model_Meta_Order $order)
$data = array(
'order_number' => $order->getOrderNumber(),
'external_order_ref' => $order->getExternalOrderRef(),
'order_status_code' => $order->getOrderStatus()->getCode(),
'order_status_label' => $order->getOrderStatus()->getLabel(),
'buyer' => array(),
'created_at' => Nosto::helper('date')->format($order->getCreatedDate()),
'payment_provider' => $order->getPaymentProvider(),
'purchased_items' => array(),
);
if ($order->getOrderStatus()) {
$data['order_status_code'] = $order->getOrderStatus()->getCode();
$data['order_status_label'] = $order->getOrderStatus()->getLabel();
}
foreach ($order->getPurchasedItems() as $item) {
$data['purchased_items'][] = array(
'product_id' => $item->getProductId(),
Expand All @@ -103,14 +105,16 @@ protected function getOrderAsJson(Nosto_Tagging_Model_Meta_Order $order)
'price_currency_code' => strtoupper($item->getCurrencyCode()),
);
}
if ($order->getBuyerInfo()->getFirstName()) {
$data['buyer']['first_name'] = $order->getBuyerInfo()->getFirstName();
}
if ($order->getBuyerInfo()->getLastName()) {
$data['buyer']['last_name'] = $order->getBuyerInfo()->getLastName();
}
if ($order->getBuyerInfo()->getEmail()) {
$data['buyer']['email'] = $order->getBuyerInfo()->getEmail();
if ($order->getBuyerInfo()) {
if ($order->getBuyerInfo()->getFirstName()) {
$data['buyer']['first_name'] = $order->getBuyerInfo()->getFirstName();
}
if ($order->getBuyerInfo()->getLastName()) {
$data['buyer']['last_name'] = $order->getBuyerInfo()->getLastName();
}
if ($order->getBuyerInfo()->getEmail()) {
$data['buyer']['email'] = $order->getBuyerInfo()->getEmail();
}
}
return json_encode($data);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Nosto/Tagging/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<config>
<modules>
<Nosto_Tagging>
<version>2.6.6</version>
<version>2.6.7</version>
</Nosto_Tagging>
</modules>
<global>
Expand Down
24 changes: 14 additions & 10 deletions app/design/frontend/base/default/template/nostotagging/order.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,22 @@ $priceHelper = Mage::helper('nosto_tagging/price');
<div class="nosto_purchase_order" style="display:none">
<span class="order_number"><?php echo $order->getOrderNumber(); ?></span>
<span class="external_order_ref"><?php echo $helper->escapeHtml($order->getExternalOrderRef()); ?></span>
<span class="order_status_code"><?php echo $helper->escapeHtml($order->getOrderStatus()->getCode()); ?></span>
<span class="order_status_label"><?php echo $helper->escapeHtml($order->getOrderStatus()->getLabel()); ?></span>
<?php if ($order->getOrderStatus()): ?>
<span class="order_status_code"><?php echo $helper->escapeHtml($order->getOrderStatus()->getCode()); ?></span>
<span class="order_status_label"><?php echo $helper->escapeHtml($order->getOrderStatus()->getLabel()); ?></span>
<?php endif; ?>
<span class="payment_provider"><?php echo $helper->escapeHtml($order->getPaymentProvider()); ?></span>
<div class="buyer">
<?php if ($order->getBuyerInfo()->getFirstName()): ?>
<span class="first_name"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getFirstName()); ?></span>
<?php endif; ?>
<?php if ($order->getBuyerInfo()->getLastName()): ?>
<span class="last_name"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getLastName()); ?></span>
<?php endif; ?>
<?php if ($order->getBuyerInfo()->getEmail()): ?>
<span class="email"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getEmail()); ?></span>
<?php if ($order->getBuyerInfo()): ?>
<?php if ($order->getBuyerInfo()->getFirstName()): ?>
<span class="first_name"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getFirstName()); ?></span>
<?php endif; ?>
<?php if ($order->getBuyerInfo()->getLastName()): ?>
<span class="last_name"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getLastName()); ?></span>
<?php endif; ?>
<?php if ($order->getBuyerInfo()->getEmail()): ?>
<span class="email"><?php echo $helper->escapeHtml($order->getBuyerInfo()->getEmail()); ?></span>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="purchased_items">
Expand Down

0 comments on commit 4bf97fa

Please sign in to comment.