Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into MAGETWO-58857
  • Loading branch information
Denys Rul committed Oct 5, 2016
2 parents 19abbdd + aba7790 commit c05ebec
Show file tree
Hide file tree
Showing 379 changed files with 19,038 additions and 3,370 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Authorizenet/Model/Source/Cctype.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class Cctype extends PaymentCctype
*/
public function getAllowedTypes()
{
return ['VI', 'MC', 'AE', 'DI'];
return ['VI', 'MC', 'AE', 'DI', 'JCB', 'DN'];
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Authorizenet/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<payment>
<authorizenet_directpost>
<active>0</active>
<cctypes>AE,VI,MC,DI</cctypes>
<cctypes>AE,VI,MC,DI,JCB,DN</cctypes>
<debug>0</debug>
<email_customer>0</email_customer>
<login backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
</label>
<div class="admin__field-control">
<select id="<?php /* @noEscape */ echo $code; ?>_cc_type" name="payment[cc_type]"
class="required-entry validate-cc-type-select admin__control-select">
<option value=""></option>
class="admin__control-select"
data-validate="{
'required':true,
'validate-cc-type-select':'#<?php /* @noEscape */ echo $code; ?>_cc_number'
}">
<option value=""><?php echo $block->escapeHtml(__('Please Select')); ?></option>
<?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?>
<option value="<?php echo $block->escapeHtml($typeCode); ?>"
<?php if ($typeCode == $ccType): ?>selected="selected"<?php endif; ?>>
Expand All @@ -46,27 +50,37 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
</select>
</div>
</div>

<div class="admin__field _required">
<label for="<?php /* @noEscape */ echo $code; ?>_cc_number" class="admin__field-label">
<span><?php echo $block->escapeHtml(__('Credit Card Number')); ?></span>
</label>

<div class="admin__field-control">
<input type="text" id="<?php /* @noEscape */ echo $code; ?>_cc_number"
name="payment[cc_number]"
class="input-text required-entry validate-cc-number admin__control-text"
data-validate="{
'required-number':true,
'validate-cc-number':'#<?php /* @noEscape */ echo $code; ?>_cc_type',
'validate-cc-type':'#<?php /* @noEscape */ echo $code; ?>_cc_type'
}"
class="admin__control-text"
value="<?php /* @noEscape */ echo $block->getInfoData('cc_number'); ?>"/>
</div>
</div>
<div class="admin__field _required">

<div class="admin__field _required field-date" id="<?php /* @noEscape */ echo $code; ?>_cc_type_exp_div">
<label for="<?php /* @noEscape */ echo $code; ?>_expiration" class="admin__field-label">
<span><?php echo $block->escapeHtml(__('Expiration Date')); ?></span>
</label>

<div class="admin__field-control">
<select id="<?php /* @noEscape */ echo $code; ?>_expiration"
name="payment[cc_exp_month]"
class="validate-cc-exp required-entry admin__control-select admin__control-select-month">
class="admin__control-select admin__control-select-month"
data-validate="{
'required':true,
'validate-cc-exp':'#<?php /* @noEscape */ echo $code; ?>_expiration_yr'
}">
<?php foreach ($block->getCcMonths() as $k => $v): ?>
<option value="<?php echo $block->escapeHtml($k); ?>"
<?php if ($k == $ccExpMonth): ?>selected="selected"<?php endif; ?>>
Expand All @@ -76,7 +90,9 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
</select>
<select id="<?php /* @noEscape */ echo $code; ?>_expiration_yr"
name="payment[cc_exp_year]"
class="required-entry admin__control-select admin__control-select-year">
class="admin__control-select admin__control-select-year"
data-container="<?php /* @noEscape */ echo $code; ?>-cc-year"
data-validate="{required:true}">
<?php foreach ($block->getCcYears() as $k => $v): ?>
<option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : ''; ?>"
<?php if ($k == $ccExpYear): ?>selected="selected"<?php endif; ?>>
Expand All @@ -86,17 +102,27 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
</select>
</div>
</div>

<?php if ($block->hasVerification()): ?>
<div class="admin__field _required">
<label for="<?php /* @noEscape */ echo $code; ?>_cc_cid">
<div class="admin__field _required field-cvv">
<label class="admin__field-label"
for="<?php /* @noEscape */ echo $code; ?>_cc_cid"
id="<?php /* @noEscape */ echo $code; ?>_cc_type_cvv_div">
<span><?php echo $block->escapeHtml(__('Card Verification Number')); ?></span>
</label>

<div class="admin__field-control">
<input type="text"
class="required-entry input-text validate-cc-cvn admin__control-text"
data-container="<?php /* @noEscape */ echo $code; ?>-cc-cvv"
title="<?php echo $block->escapeHtml(__('Card Verification Number')); ?>"
class="admin__control-text cvv"
id="<?php /* @noEscape */ echo $code; ?>_cc_cid" name="payment[cc_cid]"
value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"/>
value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"
data-validate="{
'required-number':true,
'validate-cc-cvn':'#<?php /* @noEscape */ echo $code; ?>_cc_type'
}"
autocomplete="off"/>
</div>
</div>
<?php endif; ?>
Expand All @@ -105,7 +131,7 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
require([
'prototype',
'Magento_Sales/order/create/scripts',
"Magento_Sales/order/create/form",
'Magento_Sales/order/create/form',
'Magento_Authorizenet/js/direct-post'
], function(){

Expand Down
15 changes: 7 additions & 8 deletions app/code/Magento/Braintree/Helper/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
namespace Magento\Braintree\Helper;

use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
use Magento\Braintree\Model\Adminhtml\System\Config\Country as CountryConfig;

/**
* Class Country
*/
class Country
{
/**
* @var \Magento\Directory\Model\ResourceModel\Country\CollectionFactory
* @var CollectionFactory
*/
private $collectionFactory;

/**
* @var \Magento\Braintree\Model\Adminhtml\System\Config\Country
* @var CountryConfig
*/
private $countryConfig;

Expand All @@ -28,13 +29,11 @@ class Country
private $countries;

/**
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $factory
* @param \Magento\Braintree\Model\Adminhtml\System\Config\Country $countryConfig
* @param CollectionFactory $factory
* @param CountryConfig $countryConfig
*/
public function __construct(
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $factory,
\Magento\Braintree\Model\Adminhtml\System\Config\Country $countryConfig
) {
public function __construct(CollectionFactory $factory, CountryConfig $countryConfig)
{
$this->collectionFactory = $factory;
$this->countryConfig = $countryConfig;
}
Expand Down
19 changes: 18 additions & 1 deletion app/code/Magento/Braintree/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<argument name="code" xsi:type="const">Magento\Braintree\Model\Ui\PayPal\ConfigProvider::PAYPAL_CODE</argument>
<argument name="infoBlockType" xsi:type="string">BraintreePayPalInfo</argument>
<argument name="valueHandlerPool" xsi:type="object">BraintreePayPalValueHandlerPool</argument>
<argument name="validatorPool" xsi:type="object">BraintreePayPalValidatorPool</argument>
<argument name="commandPool" xsi:type="object">BraintreePayPalCommandPool</argument>
</arguments>
</virtualType>
Expand Down Expand Up @@ -474,7 +475,7 @@
</arguments>
</virtualType>

<!-- Value validators infrastructure -->
<!-- Braintree validators infrastructure -->
<virtualType name="BraintreeCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\Config</argument>
Expand All @@ -487,6 +488,22 @@
</argument>
</arguments>
</virtualType>
<!-- Braintree validators infrastructure -->

<!-- Braintree PayPal validators -->
<virtualType name="BraintreePayPalCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\PayPal\Config</argument>
</arguments>
</virtualType>
<virtualType name="BraintreePayPalValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
<arguments>
<argument name="validators" xsi:type="array">
<item name="country" xsi:type="string">BraintreePayPalCountryValidator</item>
</argument>
</arguments>
</virtualType>
<!-- END Braintree PayPal validators -->

<type name="Magento\Braintree\Block\Info">
<arguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@ define([
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Vault/js/view/payment/vault-enabler'
], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators, VaultEnabler) {
'Magento_Vault/js/view/payment/vault-enabler',
'Magento_Checkout/js/action/create-billing-address'
], function (
$,
_,
Component,
Braintree,
quote,
fullScreenLoader,
additionalValidators,
VaultEnabler,
createBillingAddress
) {
'use strict';

return Component.extend({
Expand Down Expand Up @@ -172,14 +183,16 @@ define([
var billingAddress = {
street: [address.streetAddress],
city: address.locality,
regionCode: address.region,
postcode: address.postalCode,
countryId: address.countryCodeAlpha2,
email: customer.email,
firstname: customer.firstName,
lastname: customer.lastName,
telephone: customer.phone
};

billingAddress['region_code'] = address.region;
billingAddress = createBillingAddress(billingAddress);
quote.billingAddress(billingAddress);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
<input type="checkbox"
name="vault[is_enabled]"
class="checkbox"
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
</label>
<div class="field-tooltip toggle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<input type="checkbox"
name="vault[is_enabled]"
class="checkbox"
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
</label>
<div class="field-tooltip toggle">
Expand Down
44 changes: 31 additions & 13 deletions app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,7 @@ private function getShipmentTypeValue($type)
protected function cleanNotBundleAdditionalAttributes($dataRow)
{
if (!empty($dataRow['additional_attributes'])) {
$additionalAttributes = explode(
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
$dataRow['additional_attributes']
);
$additionalAttributes = $this->parseAdditionalAttributes($dataRow['additional_attributes']);
$dataRow['additional_attributes'] = $this->getNotBundleAttributes($additionalAttributes);
}

Expand All @@ -349,17 +346,38 @@ protected function cleanNotBundleAdditionalAttributes($dataRow)
*/
protected function getNotBundleAttributes($additionalAttributes)
{
$cleanedAdditionalAttributes = '';
foreach ($additionalAttributes as $attribute) {
list($attributeCode, $attributeValue) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attribute);
if (!in_array('bundle_' . $attributeCode, $this->getBundleColumns())) {
$cleanedAdditionalAttributes .= $attributeCode
. ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
. $attributeValue
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
$filteredAttributes = [];
foreach ($additionalAttributes as $code => $value) {
if (!in_array('bundle_' . $code, $this->getBundleColumns())) {
$filteredAttributes[] = $code . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $value;
}
}
return implode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $filteredAttributes);
}

return rtrim($cleanedAdditionalAttributes, ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
/**
* Retrieves additional attributes as array code=>value.
*
* @param string $additionalAttributes
* @return array
*/
private function parseAdditionalAttributes($additionalAttributes)
{
$attributeNameValuePairs = explode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
$preparedAttributes = [];
$code = '';
foreach ($attributeNameValuePairs as $attributeData) {
//process case when attribute has ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR inside its value
if (strpos($attributeData, ImportProductModel::PAIR_NAME_VALUE_SEPARATOR) === false) {
if (!$code) {
continue;
}
$preparedAttributes[$code] .= ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . $attributeData;
continue;
}
list($code, $value) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attributeData, 2);
$preparedAttributes[$code] = $value;
}
return $preparedAttributes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@ public function testAddHeaderColumns()
public function testAddData()
{
$preparedData = $this->rowCustomizerMock->prepareData($this->productResourceCollection, [1]);
$attributes = 'attribute=1,sku_type=1,price_type=1,price_view=1,weight_type=1,values=values,shipment_type=1';
$attributes = 'attribute=1,sku_type=1,attribute2="Text",price_type=1,price_view=1,weight_type=1,'
. 'values=values,shipment_type=1,attribute3=One,Two,Three';
$dataRow = [
'sku' => 'sku1',
'additional_attributes' => $attributes
];
$preparedRow = $preparedData->addData($dataRow, 1);
$expected = [
'sku' => 'sku1',
'additional_attributes' => 'attribute=1',
'additional_attributes' => 'attribute=1,attribute2="Text",attribute3=One,Two,Three',
'bundle_price_type' => 'fixed',
'bundle_shipment_type' => 'separately',
'bundle_sku_type' => 'fixed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,16 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
$customOptions = [];
foreach ($options as $customOptionData) {
if (empty($customOptionData['is_delete'])) {
if (empty($customOptionData['option_id'])) {
$customOptionData['option_id'] = null;
}
if (isset($customOptionData['values'])) {
$customOptionData['values'] = array_filter($customOptionData['values'], function ($valueData) {
return empty($valueData['is_delete']);
});
}
$customOption = $this->getCustomOptionFactory()->create(['data' => $customOptionData]);
$customOption->setProductSku($product->getSku());
$customOption->setOptionId(null);
$customOptions[] = $customOption;
}
}
Expand Down Expand Up @@ -255,7 +257,7 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product)

foreach ($linkTypes as $linkType => $readonly) {
if (isset($links[$linkType]) && !$readonly) {
foreach ((array) $links[$linkType] as $linkData) {
foreach ((array)$links[$linkType] as $linkData) {
if (empty($linkData['id'])) {
continue;
}
Expand Down Expand Up @@ -321,9 +323,11 @@ public function mergeProductOptions($productOptions, $overwriteOptions)

if (isset($option['values']) && isset($overwriteOptions[$optionId]['values'])) {
foreach ($option['values'] as $valueIndex => $value) {
$valueId = $value['option_type_id'];
$value = $this->overwriteValue($valueId, $value, $overwriteOptions[$optionId]['values']);
$option['values'][$valueIndex] = $value;
if (isset($value['option_type_id'])) {
$valueId = $value['option_type_id'];
$value = $this->overwriteValue($valueId, $value, $overwriteOptions[$optionId]['values']);
$option['values'][$valueIndex] = $value;
}
}
}

Expand All @@ -347,6 +351,9 @@ private function overwriteValue($optionId, $option, $overwriteOptions)
foreach ($overwriteOptions[$optionId] as $fieldName => $overwrite) {
if ($overwrite && isset($option[$fieldName]) && isset($option['default_' . $fieldName])) {
$option[$fieldName] = $option['default_' . $fieldName];
if ('title' == $fieldName) {
$option['is_delete_store_title'] = 1;
}
}
}
}
Expand Down
Loading

0 comments on commit c05ebec

Please sign in to comment.