Skip to content

Commit 1c6d457

Browse files
author
Alexander Akimov
authored
Merge pull request #1729 from magento-tsg/2.1-develop-pr35
[TSG] Backporting for 2.1 (pr35) (2.1.11)
2 parents b78362f + c9214e9 commit 1c6d457

File tree

25 files changed

+1574
-175
lines changed

25 files changed

+1574
-175
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ protected function _responseAction($area = 'frontend')
7373
$helper = $this->dataFactory->create($area);
7474

7575
$params = [];
76-
$data = $this->getRequest()->getPostValue();
76+
$data = $this->getRequest()->getParams();
77+
7778
/* @var $paymentMethod \Magento\Authorizenet\Model\DirectPost */
7879
$paymentMethod = $this->_objectManager->create('Magento\Authorizenet\Model\Directpost');
7980

@@ -110,9 +111,8 @@ protected function _responseAction($area = 'frontend')
110111
$params['redirect'] = $helper->getRedirectIframeUrl($result);
111112
}
112113

114+
//registering parameter for iframe content
113115
$this->_coreRegistry->register(Iframe::REGISTRY_KEY, $params);
114-
$this->_view->addPageLayoutHandles();
115-
$this->_view->loadLayout(false)->renderLayout();
116116
}
117117

118118
/**

app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(
5252
* Response action.
5353
* Action for Authorize.net SIM Relay Request.
5454
*
55-
* @return void
55+
* @return \Magento\Framework\Controller\ResultInterface
5656
*/
5757
public function execute()
5858
{
@@ -67,10 +67,11 @@ public function execute()
6767
$paymentMethod->validateResponse();
6868
} catch (LocalizedException $e) {
6969
$this->logger->critical($e->getMessage());
70-
$this->_redirect('noroute');
71-
return;
70+
71+
return $this->_redirect('noroute');
7272
}
7373
$this->_responseAction('adminhtml');
74-
$this->resultFactory->create(ResultFactory::TYPE_PAGE);
74+
75+
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
7576
}
7677
}

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Response.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ class Response extends \Magento\Authorizenet\Controller\Directpost\Payment
1212
* Response action.
1313
* Action for Authorize.net SIM Relay Request.
1414
*
15-
* @return void
15+
* @return \Magento\Framework\Controller\ResultInterface
1616
*/
1717
public function execute()
1818
{
1919
$this->_responseAction('frontend');
20+
21+
return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
2022
}
2123
}

app/code/Magento/Authorizenet/Model/Authorizenet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ protected function buildRequest(\Magento\Framework\DataObject $payment)
332332
->setXCity($billing->getCity())
333333
->setXState($billing->getRegion())
334334
->setXZip($billing->getPostcode())
335-
->setXCountry($billing->getCountry())
335+
->setXCountry($billing->getCountryId())
336336
->setXPhone($billing->getTelephone())
337337
->setXFax($billing->getFax())
338338
->setXCustId($order->getCustomerId())
@@ -352,7 +352,7 @@ protected function buildRequest(\Magento\Framework\DataObject $payment)
352352
->setXShipToCity($shipping->getCity())
353353
->setXShipToState($shipping->getRegion())
354354
->setXShipToZip($shipping->getPostcode())
355-
->setXShipToCountry($shipping->getCountry());
355+
->setXShipToCountry($shipping->getCountryId());
356356
}
357357

358358
$request->setXPoNum($payment->getPoNumber())

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,11 @@ protected function processPaymentFraudStatus(\Magento\Sales\Model\Order\Payment
747747
return $this;
748748
}
749749

750-
$payment->setIsFraudDetected(true);
750+
$fdsFilterAction = (string)$fraudDetailsResponse->getFdsFilterAction();
751+
if ($this->fdsFilterActionIsReportOnly($fdsFilterAction) === false) {
752+
$payment->setIsFraudDetected(true);
753+
}
754+
751755
$payment->setAdditionalInformation('fraud_details', $fraudData);
752756
} catch (\Exception $e) {
753757
//this request is optional
@@ -993,4 +997,16 @@ private function getPsrLogger()
993997
}
994998
return $this->psrLogger;
995999
}
1000+
1001+
/**
1002+
* Checks if filter action is Report Only. Transactions that trigger this filter are processed as normal,
1003+
* but are also reported in the Merchant Interface as triggering this filter.
1004+
*
1005+
* @param string $fdsFilterAction
1006+
* @return bool
1007+
*/
1008+
private function fdsFilterActionIsReportOnly($fdsFilterAction)
1009+
{
1010+
return $fdsFilterAction === (string)$this->dataHelper->getFdsFilterActionLabel('report');
1011+
}
9961012
}

app/code/Magento/Authorizenet/Model/Directpost/Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function setDataFromOrder(
123123
->setXCity(strval($billing->getCity()))
124124
->setXState(strval($billing->getRegion()))
125125
->setXZip(strval($billing->getPostcode()))
126-
->setXCountry(strval($billing->getCountry()))
126+
->setXCountry(strval($billing->getCountryId()))
127127
->setXPhone(strval($billing->getTelephone()))
128128
->setXFax(strval($billing->getFax()))
129129
->setXCustId(strval($billing->getCustomerId()))
@@ -151,7 +151,7 @@ public function setDataFromOrder(
151151
)->setXShipToZip(
152152
strval($shipping->getPostcode())
153153
)->setXShipToCountry(
154-
strval($shipping->getCountry())
154+
strval($shipping->getCountryId())
155155
);
156156
}
157157

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -651,24 +651,52 @@ protected function addFilterGroupToCollection(
651651
Collection $collection
652652
) {
653653
$fields = [];
654-
$categoryFilter = [];
654+
655655
foreach ($filterGroup->getFilters() as $filter) {
656656
$conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
657+
$isApplied = $this->applyCustomFilter($collection, $filter, $conditionType);
657658

658-
if ($filter->getField() == 'category_id') {
659-
$categoryFilter[$conditionType][] = $filter->getValue();
660-
continue;
659+
if (!$isApplied) {
660+
$fields[] = ['attribute' => $filter->getField(), $conditionType => $filter->getValue()];
661661
}
662-
$fields[] = ['attribute' => $filter->getField(), $conditionType => $filter->getValue()];
663662
}
664663

665-
if ($categoryFilter) {
664+
if ($fields) {
665+
$collection->addFieldToFilter($fields);
666+
}
667+
}
668+
669+
/**
670+
* Apply custom filters to product collection.
671+
*
672+
* @param Collection $collection
673+
* @param \Magento\Framework\Api\Filter $filter
674+
* @param string $conditionType
675+
* @return bool
676+
*/
677+
private function applyCustomFilter(Collection $collection, \Magento\Framework\Api\Filter $filter, $conditionType)
678+
{
679+
if ($filter->getField() == 'category_id') {
680+
$categoryFilter[$conditionType][] = $filter->getValue();
666681
$collection->addCategoriesFilter($categoryFilter);
682+
return true;
667683
}
668684

669-
if ($fields) {
670-
$collection->addFieldToFilter($fields);
685+
if ($filter->getField() == 'store') {
686+
$collection->addStoreFilter($filter->getValue());
687+
return true;
671688
}
689+
690+
if ($filter->getField() == 'website_id') {
691+
$value = $filter->getValue();
692+
if (strpos($value, ',') !== false) {
693+
$value = explode(',', $value);
694+
}
695+
$collection->addWebsiteFilter($value);
696+
return true;
697+
}
698+
699+
return false;
672700
}
673701

674702
/**

0 commit comments

Comments
 (0)