Skip to content

Commit

Permalink
Merge branch 'develop' into release/6.4.26
Browse files Browse the repository at this point in the history
  • Loading branch information
sta1r committed Feb 25, 2020
2 parents a8eee8c + fcbfcd8 commit 4ac906a
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 9 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ INSERT INTO `core_config_data` (`scope`, `scope_id`, `path`, `value`)
## Contribution

You are welcome to contribute to Engagement Cloud for Magento! You can either:
- Report a bug: create a [GitHub issue](https://github.com/dotmailer/dotmailer-magento-extension/issues/new) including description, repro steps, Magento and extension version numbers
- Report a bug: create a [GitHub issue](https://github.com/dotmailer/dotmailer-magento-extension/issues/new) including description, steps to reproduce, Magento and extension version numbers
- Fix a bug: please fork this repo and submit the Pull Request to our [Develop branch](https://github.com/dotmailer/dotmailer-magento-extension/tree/develop)
Request a feature on our [roadmap](https://roadmap.dotdigital.com)

# 6.4.26

###### What’s new
- Codes for campaign tracking and ROI tracking applied to the **Get basket** link in the abandoned cart EDC are now preserved and applied at their destination.

###### Fixes
- Exclusion rules can now have conditions relating to product attribute sets.

# 6.4.25

###### What's new
Expand Down
16 changes: 15 additions & 1 deletion code/Dotdigitalgroup/Email/Model/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ protected function _processProductAttributes($collection)
Mage_Catalog_Model_Product::ENTITY,
$product
);

$attributes[] = 'attribute_set_id';
foreach ($this->productAttribute as $productAttribute) {
$attribute = $productAttribute['attribute'];
$cond = $productAttribute['conditions'];
Expand Down Expand Up @@ -436,6 +436,11 @@ protected function _processProductAttributes($collection)
}

$attributeValue = call_user_func(array($product, $getter));

if ($getter === 'getAttributeSetId') {
$attributeValue = $this->getAttributeCode($attributeValue);
}

//if retrieved value is an array then loop through all array values. Ex. categories
if (is_array($attributeValue)) {
foreach ($attributeValue as $attrValue) {
Expand Down Expand Up @@ -499,4 +504,13 @@ protected function _evaluate($varOne, $op, $varTwo)

return false;
}

/**
* @param $attributeId
* @return string
*/
protected function getAttributeCode($attributeId)
{
return Mage::getModel('eav/entity_attribute_set')->load($attributeId)->getAttributeSetName();
}
}
70 changes: 64 additions & 6 deletions code/Dotdigitalgroup/Email/controllers/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class Dotdigitalgroup_Email_EmailController
*/
protected $_quote;

/**
* @var string
*/
protected $redirectParams;

/**
* wishlist
*/
Expand Down Expand Up @@ -182,14 +187,18 @@ public function getbasketAction()
$quoteId = $this->getRequest()->getParam('quote_id');
//no quote id redirect to base url
if (!$quoteId) {
$this->_redirectUrl(Mage::getBaseUrl());
$this->_redirectUrl(
$this->getRedirectWithParams(Mage::getBaseUrl())
);
}

$quoteModel = Mage::getModel('sales/quote')->load($quoteId);

//no quote id redirect to base url
if (!$quoteModel->getId()) {
$this->_redirectUrl(Mage::getBaseUrl());
$this->_redirectUrl(
$this->getRedirectWithParams(Mage::getBaseUrl())
);
}

//set quoteModel to _quote property for later use
Expand Down Expand Up @@ -225,7 +234,9 @@ protected function _handleCustomerBasket()
$url = 'checkout/cart';
}

$this->_redirectUrl($this->_quote->getStore()->getUrl($url));
$this->_redirectUrl(
$this->getRedirectWithParams($this->_quote->getStore()->getUrl($url))
);
} else {
// customer will be redirected to cart after successful login
if ($configCartUrl) {
Expand All @@ -235,7 +246,7 @@ protected function _handleCustomerBasket()
}

$customerSession->setAfterAuthUrl(
$this->_quote->getStore()->getUrl($cartUrl)
$this->getRedirectWithParams($this->_quote->getStore()->getUrl($cartUrl))
);

//send customer to login page
Expand All @@ -249,7 +260,9 @@ protected function _handleCustomerBasket()
$loginUrl = 'customer/account/login';
}

$this->_redirectUrl($this->_quote->getStore()->getUrl($loginUrl));
$this->_redirectUrl(
$this->getRedirectWithParams($this->_quote->getStore()->getUrl($loginUrl))
);
}
}

Expand All @@ -268,7 +281,52 @@ protected function _handleGuestBasket()
$url = 'checkout/cart';
}

$this->_redirectUrl($this->_quote->getStore()->getUrl($url));
$this->_redirectUrl(
$this->getRedirectWithParams($this->_quote->getStore()->getUrl($url))
);
}

/**
* Get the URL to redirect, maintaining any query string parameters passed
*
* @param string $path
* @return string
*/
protected function getRedirectWithParams($path)
{
if (!empty($this->redirectParams)) {
return $this->redirectParams;
}

// get any params without quote_id
$params = array_diff_key($this->getRequest()->getParams(), ['quote_id' => null]);
if (empty($params)) {
return $path;
}

$this->redirectParams = $params;

// dm_i params are exceptional because they cannot be altered in the process of encoding
$dm_i = null;
if (isset($params['dm_i'])) {
$dm_i = $params['dm_i'];
unset($params['dm_i']);
}

$redirectWithParams = sprintf(
'%s%s%s',
$path,
strpos($path, '?') !== false ? '&' : '?',
http_build_query($params, null, "&", PHP_QUERY_RFC3986)
);

if ($dm_i) {
return $redirectWithParams .
($params ? '&' : '') .
'dm_i=' . $dm_i;
}

return $redirectWithParams;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion code/Dotdigitalgroup/Email/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Dotdigitalgroup_Email>
<version>6.4.25</version>
<version>6.4.26</version>
</Dotdigitalgroup_Email>
</modules>
<frontend>
Expand Down

0 comments on commit 4ac906a

Please sign in to comment.