Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/develop' into MAGETWO-24139
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergii Kovalenko committed Aug 18, 2016
2 parents cdb77aa + 6e64d1c commit 7a71c1c
Show file tree
Hide file tree
Showing 45 changed files with 1,651 additions and 204 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ public function __construct(
public function build($productId)
{
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$productTable = $this->resource->getTableName('catalog_product_entity');

return [$this->resource->getConnection()->select()
->from(['parent' => 'catalog_product_entity'], '')
->from(['parent' => $productTable], '')
->joinInner(
['link' => $this->resource->getTableName('catalog_product_relation')],
"link.parent_id = parent.$linkField",
[]
)->joinInner(
['child' => 'catalog_product_entity'],
['child' => $productTable],
"child.entity_id = link.child_id",
['entity_id']
)->joinInner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ public function build($productId)
{
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$priceAttribute = $this->eavConfig->getAttribute(Product::ENTITY, 'price');
$productTable = $this->resource->getTableName('catalog_product_entity');

$priceSelect = $this->resource->getConnection()->select()
->from(['parent' => 'catalog_product_entity'], '')
->from(['parent' => $productTable], '')
->joinInner(
['link' => $this->resource->getTableName('catalog_product_relation')],
"link.parent_id = parent.$linkField",
[]
)->joinInner(
['child' => 'catalog_product_entity'],
['child' => $productTable],
"child.entity_id = link.child_id",
['entity_id']
)->joinInner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ public function build($productId)
$specialPriceToDate = $this->eavConfig->getAttribute(Product::ENTITY, 'special_to_date');
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
$currentDate = $this->dateTime->formatDate($timestamp, false);
$productTable = $this->resource->getTableName('catalog_product_entity');

$specialPrice = $this->resource->getConnection()->select()
->from(['parent' => 'catalog_product_entity'], '')
->from(['parent' => $productTable], '')
->joinInner(
['link' => $this->resource->getTableName('catalog_product_relation')],
"link.parent_id = parent.$linkField",
[]
)->joinInner(
['child' => 'catalog_product_entity'],
['child' => $productTable],
"child.entity_id = link.child_id",
['entity_id']
)->joinInner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ public function __construct(
public function build($productId)
{
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$productTable = $this->resource->getTableName('catalog_product_entity');

$priceSelect = $this->resource->getConnection()->select()
->from(['parent' => 'catalog_product_entity'], '')
->from(['parent' => $productTable], '')
->joinInner(
['link' => $this->resource->getTableName('catalog_product_relation')],
"link.parent_id = parent.$linkField",
[]
)->joinInner(
['child' => 'catalog_product_entity'],
['child' => $productTable],
"child.entity_id = link.child_id",
['entity_id']
)->joinInner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
</div>
</div>
<?php endif; ?>
<?php if ($block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
Expand All @@ -49,11 +50,11 @@
}
}
</script>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
<?php else : ?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"catalogAddToCart": {}
"Magento_Catalog/js/validate-product": {}
}
}
</script>
Expand Down
48 changes: 48 additions & 0 deletions app/code/Magento/Catalog/view/frontend/web/js/validate-product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'mage/mage',
'Magento_Catalog/product/view/validation',
'catalogAddToCart'
], function ($) {
'use strict';

$.widget('mage.productValidate', {
options: {
bindSubmit: false,
radioCheckboxClosest: '.nested'
},

/**
* Uses Magento's validation widget for the form object.
* @private
*/
_create: function () {
var bindSubmit = this.options.bindSubmit;

this.element.validation({
radioCheckboxClosest: this.options.radioCheckboxClosest,

/**
* Uses catalogAddToCart widget as submit handler.
* @param {Object} form
* @returns {Boolean}
*/
submitHandler: function (form) {
var jqForm = $(form).catalogAddToCart({
bindSubmit: bindSubmit
});

jqForm.catalogAddToCart('submitForm', jqForm);

return false;
}
});
}
});

return $.mage.productValidate;
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ public function build($productId)
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
$currentDate = $this->dateTime->formatDate($timestamp, false);
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$productTable = $this->resource->getTableName('catalog_product_entity');

return [$this->resource->getConnection()->select()
->from(['parent' => 'catalog_product_entity'], '')
->from(['parent' => $productTable], '')
->joinInner(
['link' => $this->resource->getTableName('catalog_product_relation')],
"link.parent_id = parent.$linkField",
[]
)->joinInner(
['child' => 'catalog_product_entity'],
['child' => $productTable],
"child.entity_id = link.child_id",
['entity_id']
)->joinInner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<!-- ko if: gridNew().length -->
<!-- ko template: {name: getGridTemplate(), data: {
grid: gridNew,
paging: pagingNew,
id: getGridId(),
title: $t('New Product Review'),
note: $t('Here are the products you\'re about to create.')
Expand All @@ -25,6 +26,7 @@

<!-- ko if: gridExisting().length -->
<!-- ko template: {name: getGridTemplate(), data: {
paging: pagingExisting,
grid: gridExisting,
id: getGridId(),
title: $t('Associated Products'),
Expand All @@ -34,6 +36,7 @@

<!-- ko if: gridDeleted().length -->
<!-- ko template: {name: getGridTemplate(), data: {
paging: pagingDeleted,
grid: gridDeleted,
id: getGridId(),
title: $t('Disassociated Products'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'Magento_Ui/js/grid/paging/sizes'
], function (Sizes) {
'use strict';

return Sizes.extend({
defaults: {
excludedOptions: ['100', '200']
},

/**
* @override
*/
initialize: function () {
this._super();

this.excludedOptions.forEach(function (excludedOption) {
delete this.options[excludedOption];
}, this);
this.updateArray();

return this;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ define([
'jquery',
'ko',
'underscore',
'Magento_Ui/js/grid/paging/paging',
'mage/translate'
], function (Component, $, ko, _) {
], function (Component, $, ko, _, paging) {
'use strict';

return Component.extend({
Expand All @@ -25,31 +26,70 @@ define([
gridExisting: [],
gridNew: [],
gridDeleted: [],
variationsExisting: [],
variationsNew: [],
variationsDeleted: [],
pagingExisting: paging({
name: 'configurableWizard.pagingExisting',
sizesConfig: {
component: 'Magento_ConfigurableProduct/js/variations/paging/sizes',
name: 'configurableWizard.pagingExisting_sizes'
}
}),
pagingNew: paging({
name: 'configurableWizard.pagingNew',
sizesConfig: {
component: 'Magento_ConfigurableProduct/js/variations/paging/sizes',
name: 'configurableWizard.pagingNew_sizes'
}
}),
pagingDeleted: paging({
name: 'configurableWizard.pagingDeleted',
sizesConfig: {
component: 'Magento_ConfigurableProduct/js/variations/paging/sizes',
name: 'configurableWizard.pagingDeleted_sizes'
}
}),
attributes: [],
attributesName: [$.mage.__('Images'), $.mage.__('SKU'), $.mage.__('Quantity'), $.mage.__('Price')],
sections: [],
gridTemplate: 'Magento_ConfigurableProduct/variations/steps/summary-grid'
},
initObservable: function () {
var pagingObservables = {
currentNew: ko.getObservable(this.pagingNew, 'current'),
currentExisting: ko.getObservable(this.pagingExisting, 'current'),
currentDeleted: ko.getObservable(this.pagingDeleted, 'current'),
pageSizeNew: ko.getObservable(this.pagingNew, 'pageSize'),
pageSizeExisting: ko.getObservable(this.pagingExisting, 'pageSize'),
pageSizeDeleted: ko.getObservable(this.pagingDeleted, 'pageSize')
};

this._super().observe('gridExisting gridNew gridDeleted attributes sections');
this.gridExisting.columns = ko.observableArray();
this.gridNew.columns = ko.observableArray();
this.gridDeleted.columns = ko.observableArray();

_.each(pagingObservables, function (observable) {
observable.subscribe(function () {
this.generateGrid();
}, this);
}, this);

return this;
},
nextLabelText: $.mage.__('Generate Products'),
variations: [],
generateGrid: function (variations, getSectionValue) {
calculate: function (variations, getSectionValue) {
var productSku = this.variationsComponent().getProductValue('sku'),
productPrice = this.variationsComponent().getProductPrice(),
productWeight = this.variationsComponent().getProductValue('weight'),
variationsKeys = [],
gridExisting = [],
gridNew = [],
gridDeleted = [];
this.variations = [];

this.variations = [];
_.each(variations, function (options) {
var product, images, sku, quantity, price, variation,
productId = this.variationsComponent().getProductIdByOptions(options);
Expand Down Expand Up @@ -101,14 +141,6 @@ define([
variationsKeys.push(this.variationsComponent().getVariationKey(options));
}, this);

this.gridExisting(gridExisting);
this.gridExisting.columns(this.getColumnsName(this.wizard.data.attributes));

if (gridNew.length > 0) {
this.gridNew(gridNew);
this.gridNew.columns(this.getColumnsName(this.wizard.data.attributes));
}

_.each(_.omit(this.variationsComponent().productAttributesMap, variationsKeys), function (productId) {
gridDeleted.push(this.prepareRowForGrid(
_.findWhere(this.variationsComponent().variations, {
Expand All @@ -117,13 +149,28 @@ define([
));
}.bind(this));

if (gridDeleted.length > 0) {
this.gridDeleted(gridDeleted);
this.gridDeleted.columns(this.getColumnsName(this.variationsComponent().productAttributes));
}
this.variationsExisting = gridExisting;
this.variationsNew = gridNew;
this.variationsDeleted = gridDeleted;

},
generateGrid: function () {
var pageExisting = this.pagingExisting.pageSize * this.pagingExisting.current,
pageNew = this.pagingNew.pageSize * this.pagingNew.current,
pageDeleted = this.pagingDeleted.pageSize * this.pagingDeleted.current;

this.pagingExisting.totalRecords = this.variationsExisting.length;
this.gridExisting(this.variationsExisting.slice(pageExisting - this.pagingExisting.pageSize, pageExisting));

this.pagingNew.totalRecords = this.variationsNew.length;
this.gridNew(this.variationsNew.slice(pageNew - this.pagingNew.pageSize, pageNew));

this.pagingDeleted.totalRecords = this.variationsDeleted.length;
this.gridDeleted(this.variationsDeleted.slice(pageDeleted - this.pagingDeleted.pageSize, pageDeleted));
},
prepareRowForGrid: function (variation) {
var row = [];

row.push(_.extend({
images: []
}, variation.images));
Expand Down Expand Up @@ -158,7 +205,11 @@ define([
this.gridNew([]);
this.gridExisting([]);
this.gridDeleted([]);
this.generateGrid(wizard.data.variations, wizard.data.sectionHelper);
this.gridExisting.columns(this.getColumnsName(this.wizard.data.attributes));
this.gridNew.columns(this.getColumnsName(this.wizard.data.attributes));
this.gridDeleted.columns(this.getColumnsName(this.variationsComponent().productAttributes));
this.calculate(wizard.data.variations, wizard.data.sectionHelper);
this.generateGrid();
},
force: function () {
this.variationsComponent().render(this.variations, this.attributes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
</div>

<div class="fieldset-wrapper-content in collapse" data-collapsed="true" data-bind="attr: {id: id}">
<!-- ko template: {
name: "ui/grid/paging/paging", data: paging
} -->
<!-- /ko -->
<div class="note" data-bind="text: note"></div>
<table class="data-grid data-grid-configurable">
<thead>
Expand All @@ -23,7 +27,7 @@

<tbody>
<tr repeat="foreach: grid, item: '$product'">
<!-- ko fastForEach: { data: $product(), as: 'property' } -->
<!-- ko foreach: { data: $product(), as: 'property' } -->
<td if="property && property.preview" class="data-grid-thumbnail-cell">
<div class="images-uploaded">
<img data-bind="attr: {src: property.preview}"/>
Expand Down
Loading

0 comments on commit 7a71c1c

Please sign in to comment.