-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-58503: [Backport] - [Github] Add Configurable Product To Cart…
- Loading branch information
1 parent
8ffe3cc
commit 640991b
Showing
24 changed files
with
855 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/code/Magento/Swatches/view/frontend/web/js/catalog-add-to-cart.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
require([ | ||
'jquery' | ||
], function ($) { | ||
'use strict'; | ||
|
||
$('body').on('catalogCategoryAddToCartRedirect', function (event, data) { | ||
$(data.form).find('[name*="super"]').each(function (index, item) { | ||
var $item = $(item); | ||
|
||
data.redirectParameters.push($item.attr('data-attr-name') + '=' + $item.val()); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ViewWithSwatches.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Swatches\Test\Block\Product; | ||
|
||
use Magento\Catalog\Test\Block\Product\View; | ||
use Magento\Mtf\Fixture\FixtureInterface; | ||
|
||
/** | ||
* Configurable product view block with swatch attributes on frontend product page. | ||
*/ | ||
class ViewWithSwatches extends View | ||
{ | ||
/** | ||
* Selector for swatch attribute value. | ||
* | ||
* @var string | ||
*/ | ||
private $swatchAttributeSelector = '.swatch-attribute.%s .swatch-attribute-selected-option'; | ||
|
||
/** | ||
* Get chosen options from the product view page. | ||
* | ||
* @param FixtureInterface $product | ||
* @return array | ||
*/ | ||
public function getSelectedSwatchOptions(FixtureInterface $product) | ||
{ | ||
/** @var array $checkoutData */ | ||
$checkoutData = $product->getCheckoutData(); | ||
|
||
/** @var array $availableAttributes */ | ||
$availableAttributes = $product->getConfigurableAttributesData(); | ||
|
||
/** @var array $attributesData */ | ||
$attributesData = $availableAttributes['attributes_data']; | ||
|
||
/** @var array $formData */ | ||
$formData = []; | ||
|
||
/** @var array $item */ | ||
foreach ($checkoutData['options']['configurable_options'] as $item) { | ||
/** @var string $selector */ | ||
$selector = sprintf( | ||
$this->swatchAttributeSelector, | ||
$attributesData[$item['title']]['attribute_code'] | ||
); | ||
|
||
$this->waitForElementVisible($selector); | ||
|
||
/** @var string $selected */ | ||
$selected = $this->_rootElement->find($selector)->getText(); | ||
|
||
$formData[$item['title']] = $selected; | ||
} | ||
|
||
return $formData; | ||
} | ||
} |
Oops, something went wrong.