Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into MAGETWO-40818-Tr…
Browse files Browse the repository at this point in the history
…ansactional-Email-Templates
  • Loading branch information
arkadiych committed Aug 10, 2015
2 parents aa4646f + eef95ce commit 226654b
Show file tree
Hide file tree
Showing 763 changed files with 36,210 additions and 14,006 deletions.
20 changes: 18 additions & 2 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
*/
protected $orderFactory;

/**
* @var \Magento\Sales\Api\TransactionRepositoryInterface
*/
protected $transactionRepository;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
Expand All @@ -129,6 +134,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender
* @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
Expand All @@ -151,6 +157,7 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
\Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender,
\Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
Expand All @@ -160,6 +167,7 @@ public function __construct(
$this->quoteRepository = $quoteRepository;
$this->response = $responseFactory->create();
$this->orderSender = $orderSender;
$this->transactionRepository = $transactionRepository;
$this->_code = static::METHOD_CODE;

parent::__construct(
Expand Down Expand Up @@ -795,7 +803,11 @@ protected function declineOrder(\Magento\Sales\Model\Order $order, $message = ''
*/
protected function getRealParentTransactionId($payment)
{
$transaction = $payment->getTransaction($payment->getParentTransactionId());
$transaction = $this->transactionRepository->getByTransactionId(
$payment->getParentTransactionId(),
$payment->getId(),
$payment->getOrder()->getId()
);
return $transaction->getAdditionalInformation(self::REAL_TRANSACTION_ID_KEY);
}

Expand Down Expand Up @@ -851,7 +863,11 @@ public function canCapture()
*/
public function fetchTransactionInfo(\Magento\Payment\Model\InfoInterface $payment, $transactionId)
{
$transaction = $payment->getTransaction($transactionId);
$transaction = $this->transactionRepository->getByTransactionId(
$transactionId,
$payment->getId(),
$payment->getOrder()->getId()
);

$response = $this->getTransactionResponse($transactionId);
if ($response->getXResponseCode() == self::RESPONSE_CODE_APPROVED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,25 @@ $numColumns = sizeof($block->getColumns());
</div>
<?php if ($block->canDisplayContainer()): ?>
<script>
var deps = ['mage/adminhtml/grid'];
var deps = [];

<?php if ($block->getDependencyJsObject()): ?>
deps.push('uiRegistry');
<?php endif; ?>

<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
deps.push('Magento_Sales/order/create/form')
deps.push('Magento_Sales/order/create/form');
<?php endif; ?>

require(deps, function(){
deps.push('mage/adminhtml/grid');

require(deps, function(<?php echo ($block->getDependencyJsObject() ? 'registry' : '') ?>){
<?php //TODO: getJsObjectName and getRowClickCallback has unexpected behavior. Should be removed ?>

<?php if ($block->getDependencyJsObject()): ?>
registry.get('<?php echo $block->getDependencyJsObject() ?>', function (<?php echo $block->getDependencyJsObject() ?>) {
<?php endif; ?>

<?php echo $block->getJsObjectName() ?> = new varienGrid('<?php echo $block->getId() ?>', '<?php echo $block->getGridUrl() ?>', '<?php echo $block->getVarNamePage() ?>', '<?php echo $block->getVarNameSort() ?>', '<?php echo $block->getVarNameDir() ?>', '<?php echo $block->getVarNameFilter() ?>');
<?php echo $block->getJsObjectName() ?>.useAjax = '<?php echo $block->getUseAjax() ?>';
<?php if ($block->getRowClickCallback()): ?>
Expand All @@ -74,6 +84,10 @@ require(deps, function(){
<?php echo $block->getMassactionBlock()->getJavaScript() ?>
<?php endif ?>

<?php if ($block->getDependencyJsObject()): ?>
});
<?php endif; ?>

});
</script>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,25 @@ $numColumns = sizeof($block->getColumns());
<?php if ($block->canDisplayContainer()): ?>
</div>
<script>
var deps = ['mage/adminhtml/grid'];
var deps = [];

<?php if ($block->getDependencyJsObject()): ?>
deps.push('uiRegistry');
<?php endif; ?>

<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
deps.push('Magento_Sales/order/create/form');
deps.push('Magento_Sales/order/create/form')
<?php endif; ?>

require(deps, function(){
deps.push('mage/adminhtml/grid');

require(deps, function(<?php echo ($block->getDependencyJsObject() ? 'registry' : '') ?>){
<?php //TODO: getJsObjectName and getRowClickCallback has unexpected behavior. Should be removed ?>

<?php if ($block->getDependencyJsObject()): ?>
registry.get('<?php echo $block->getDependencyJsObject() ?>', function (<?php echo $block->getDependencyJsObject() ?>) {
<?php endif; ?>

<?php echo $block->getJsObjectName() ?> = new varienGrid('<?php echo $block->getId() ?>', '<?php echo $block->getGridUrl() ?>', '<?php echo $block->getVarNamePage() ?>', '<?php echo $block->getVarNameSort() ?>', '<?php echo $block->getVarNameDir() ?>', '<?php echo $block->getVarNameFilter() ?>');
<?php echo $block->getJsObjectName() ?>.useAjax = <?php echo $block->getUseAjax() ? 'true' : 'false' ?>;
<?php if ($block->getRowClickCallback()): ?>
Expand All @@ -171,6 +181,10 @@ $numColumns = sizeof($block->getColumns());
<?php echo $block->getChildBlock('grid.massaction')->getJavaScript() ?>
<?php endif ?>
<?php echo $block->getAdditionalJavaScript(); ?>

<?php if ($block->getDependencyJsObject()): ?>
});
<?php endif; ?>
});
</script>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,26 @@ $numColumns = sizeof($block->getColumns());
<?php if ($block->canDisplayContainer()): ?>
</div>
<script>
var deps = ['mage/adminhtml/grid'];
var deps = [];

<?php if ($block->getDependencyJsObject()): ?>
deps.push('uiRegistry');
<?php endif; ?>

<?php if (strpos($block->getRowClickCallback(), 'order.') !== false): ?>
deps.push('Magento_Sales/order/create/form')
<?php endif; ?>

require(deps, function(){
deps.push('mage/adminhtml/grid');

require(deps, function(<?php echo ($block->getDependencyJsObject() ? 'registry' : '') ?>){
<?php //TODO: getJsObjectName and getRowClickCallback has unexpected behavior. Should be removed ?>

//<![CDATA[
<?php if ($block->getDependencyJsObject()): ?>
registry.get('<?php echo $block->getDependencyJsObject() ?>', function (<?php echo $block->getDependencyJsObject() ?>) {
<?php endif; ?>

<?php echo $block->getJsObjectName() ?> = new varienGrid('<?php echo $block->getId() ?>', '<?php echo $block->getGridUrl() ?>', '<?php echo $block->getVarNamePage() ?>', '<?php echo $block->getVarNameSort() ?>', '<?php echo $block->getVarNameDir() ?>', '<?php echo $block->getVarNameFilter() ?>');
<?php echo $block->getJsObjectName() ?>.useAjax = '<?php echo $block->getUseAjax() ?>';
<?php if ($block->getRowClickCallback()): ?>
Expand All @@ -269,6 +279,10 @@ $numColumns = sizeof($block->getColumns());
<?php echo $block->getMassactionBlock()->getJavaScript() ?>
<?php endif ?>
<?php echo $block->getAdditionalJavaScript(); ?>

<?php if ($block->getDependencyJsObject()): ?>
});
<?php endif; ?>
//]]>

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public function testAuthorizeSuccess(
$this->assertEquals($this->model, $this->model->authorize($paymentObject, $amount));
foreach ($expectedPaymentFields as $key => $value) {
if ($key == 'getTransactionAdditionalInfo') {
$this->assertEquals($value, $paymentObject->getTransactionAdditionalInfo('token'));
$this->assertEquals($value, $paymentObject->getTransactionAdditionalInfo());
} else {
$this->assertEquals($value, $paymentObject->getData($key), 'Incorrect field in paymentobject: ' . $key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public function testAuthorizeSuccess(
$this->assertEquals($this->model, $this->model->authorize($paymentObject, $amount));
foreach ($expectedPaymentFields as $key => $value) {
if ($key == 'getTransactionAdditionalInfo') {
$this->assertEquals($value, $paymentObject->getTransactionAdditionalInfo('token'));
$this->assertEquals($value, $paymentObject->getTransactionAdditionalInfo());
} else {
$this->assertEquals($value, $paymentObject->getData($key), 'Incorrect field in paymentobject: ' . $key);
}
Expand Down Expand Up @@ -1385,7 +1385,7 @@ public function authorizeDataProvider()
'processorResponseCode' => '1000',
'processorResponseText' => 'Approved',
],
'getTransactionAdditionalInfo' => self::CC_TOKEN
'getTransactionAdditionalInfo' => ['token' => self::CC_TOKEN]
],
],
'token_with_3dsecure' => [
Expand Down Expand Up @@ -1458,7 +1458,7 @@ public function authorizeDataProvider()
'processorResponseCode' => '1000',
'processorResponseText' => 'Approved',
],
'getTransactionAdditionalInfo' => self::CC_TOKEN
'getTransactionAdditionalInfo' => ['token' => self::CC_TOKEN]
],
],
'token_with_3dsecure_backend' => [
Expand Down Expand Up @@ -1526,7 +1526,7 @@ public function authorizeDataProvider()
'processorResponseCode' => '1000',
'processorResponseText' => 'Approved',
],
'getTransactionAdditionalInfo' => self::CC_TOKEN
'getTransactionAdditionalInfo' => ['token' => self::CC_TOKEN]
],
'appState' => 'adminhtml',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,48 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Bundle\Model;
namespace Magento\Bundle\Observer;

/**
* Bundle Products Observer
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Observer
class AppendUpsellProducts
{
/**
* Bundle data
*
* @var \Magento\Bundle\Helper\Data
*/
protected $_bundleData = null;

/**
* Catalog helper
*
* @var \Magento\Catalog\Helper\Catalog
*/
protected $_helperCatalog = null;
protected $bundleData;

/**
* @var \Magento\Bundle\Model\Resource\Selection
*/
protected $_bundleSelection;
protected $bundleSelection;

/**
* @var \Magento\Catalog\Model\Config
*/
protected $_config;
protected $config;

/**
* @var \Magento\Catalog\Model\Product\Visibility
*/
protected $_productVisibility;
protected $productVisibility;

/**
* @param \Magento\Bundle\Helper\Data $bundleData
* @param \Magento\Catalog\Model\Product\Visibility $productVisibility
* @param \Magento\Catalog\Model\Config $config
* @param \Magento\Bundle\Model\Resource\Selection $bundleSelection
* @param \Magento\Catalog\Helper\Catalog $helperCatalog
* @param \Magento\Bundle\Helper\Data $bundleData
*/
public function __construct(
\Magento\Bundle\Helper\Data $bundleData,
\Magento\Catalog\Model\Product\Visibility $productVisibility,
\Magento\Catalog\Model\Config $config,
\Magento\Bundle\Model\Resource\Selection $bundleSelection,
\Magento\Catalog\Helper\Catalog $helperCatalog,
\Magento\Bundle\Helper\Data $bundleData
\Magento\Bundle\Model\Resource\Selection $bundleSelection
) {
$this->_helperCatalog = $helperCatalog;
$this->_bundleData = $bundleData;
$this->_bundleSelection = $bundleSelection;
$this->_config = $config;
$this->_productVisibility = $productVisibility;
$this->bundleData = $bundleData;
$this->productVisibility = $productVisibility;
$this->config = $config;
$this->bundleSelection = $bundleSelection;
}

/**
Expand All @@ -70,15 +55,15 @@ public function __construct(
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function appendUpsellProducts($observer)
public function invoke($observer)
{
/* @var $product \Magento\Catalog\Model\Product */
$product = $observer->getEvent()->getProduct();

/**
* Check is current product type is allowed for bundle selection product type
*/
if (!in_array($product->getTypeId(), $this->_bundleData->getAllowedSelectionTypes())) {
if (!in_array($product->getTypeId(), $this->bundleData->getAllowedSelectionTypes())) {
return $this;
}

Expand All @@ -94,7 +79,7 @@ public function appendUpsellProducts($observer)
}

/* @var $resource \Magento\Bundle\Model\Resource\Selection */
$resource = $this->_bundleSelection;
$resource = $this->bundleSelection;

$productIds = array_keys($collection->getItems());
if ($limit !== null && $limit <= count($productIds)) {
Expand All @@ -112,9 +97,9 @@ public function appendUpsellProducts($observer)

/* @var $bundleCollection \Magento\Catalog\Model\Resource\Product\Collection */
$bundleCollection = $product->getCollection()->addAttributeToSelect(
$this->_config->getProductAttributes()
$this->config->getProductAttributes()
)->addStoreFilter()->addMinimalPrice()->addFinalPrice()->addTaxPercents()->setVisibility(
$this->_productVisibility->getVisibleInCatalogIds()
$this->productVisibility->getVisibleInCatalogIds()
);

if ($limit !== null) {
Expand Down Expand Up @@ -142,50 +127,4 @@ public function appendUpsellProducts($observer)

return $this;
}

/**
* Add price index data for catalog product collection
* only for front end
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function loadProductOptions($observer)
{
$collection = $observer->getEvent()->getCollection();
/* @var $collection \Magento\Catalog\Model\Resource\Product\Collection */
$collection->addPriceData();

return $this;
}

/**
* Setting attribute tab block for bundle
*
* @param \Magento\Framework\DataObject $observer
* @return $this
*/
public function setAttributeTabBlock($observer)
{
$product = $observer->getEvent()->getProduct();
if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
$this->_helperCatalog->setAttributeTabBlock(
'Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes'
);
}
return $this;
}

/**
* Initialize product options renderer with bundle specific params
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function initOptionRenderer(\Magento\Framework\Event\Observer $observer)
{
$block = $observer->getBlock();
$block->addOptionsRenderCfg('bundle', 'Magento\Bundle\Helper\Catalog\Product\Configuration');
return $this;
}
}
Loading

0 comments on commit 226654b

Please sign in to comment.