Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #18795: [Forwardport] Fix customer unsubscribed issue (by @janakbhimani)
 - #18788: Remove useless semicolon statements (by @mage2pratik)
 - #18792: Remove unnecessary conditional statements (by @gy741)
 - #18782: [Forwardport] 15259 : Unable to disable without providing Industry value (by @mage2pratik)
 - #18771: Cover \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Grid\Collection class with Integration test (by @TomashKhamlai)
 - #18764: Replace intval() function by using direct type casting to (int) (by @gelanivishal)
 - #18751: Language cleanup on mass actions from the Customers grid (by @p-maguire)
 - #18756: Remove Duplicate field (by @gy741)
 - #18714: Fix for Issue #4468 "Unable to insert multiple catalog product list widgets (with pager) in CMS page" (by @vasilii-b)
 - #18730: Sections LESS mixins: fix the issue with missing rules and incorrect default variables (by @dmytro-ch)
 - #18689: ISSUE-5021 - fixed place order for custom shipping methods with under… (by @idziakjakub)
 - #18720: Prevent exception when option text converts to false (by @pmclain)
 - #18725: Fix Useless use of Cat (by @gy741)
 - #18412: Fixes #18357 - SQL error when table prefix used. (by @pocallaghan)
 - magento-engcom/import-export-improvements#120: MAGETWO-34709 Changing empty label value for first option on dropdown filters. (by @valentinboyanov)
 - #18704: Allow set billing information via API with existing address (by @pmclain)
 - #18095: #17744 Adding logic to get default billing address used on Cart and Checkout (by @LucasCalazans)
 - #18679: Set fallback values for email and _website columns to avoid 'undefined index' error in CustomerComposite.php (by @TomashKhamlai)
 - #18639: Fix SKU limit in import new products (by @ravi-chandra3197)
 - #18622: [BUGFIX] [issue-10205] Always set the entity_type_id for updating pro� (by @lewisvoncken)
 - #18611: Ensure integer values are not quoted as strings (by @udovicic)
 - #18631: Reference pull request of #18604 for 2.3-develop (by @maheshWebkul721)
 - #18388: Add class into image builder (by @VincentMarmiesse)
 - #18790: fixed Product Advanced Pricing design issue #18775 (by @ashutoshwebkul)
 - #18019: Adding trimming sku value function to sku backend model. (by @bartoszkubicki)


Fixed GitHub Issues:
 - #17954: Customer get unsubscribe to newsletter on password reset email request with Newsletter Need to Confirm Set to Yes on admin settings (reported by @matin73) has been fixed in #18795 by @janakbhimani in 2.3-develop branch
   Related commits:
     1. 6e9d5e5

 - #15259: Advanced Reporting > Unable to disable without providing Industry value (reported by @Detzler) has been fixed in #18782 by @mage2pratik in 2.3-develop branch
   Related commits:
     1. 6862c04

 - #18357: checkout_agreement_store doesn't exist (reported by @michelecanal) has been fixed in #18771 by @TomashKhamlai in 2.3-develop branch
   Related commits:
     1. 3cba00c
     2. 86e035f

 - #4468: Unable to insert multiple catalog product list widgets in CMS page (reported by @kandrejevs) has been fixed in #18714 by @vasilii-b in 2.3-develop branch
   Related commits:
     1. 0a25364

 - #18729: Bug in "_sections.less" mixins: missing rules and incorrect default variables (reported by @dmytro-ch) has been fixed in #18730 by @dmytro-ch in 2.3-develop branch
   Related commits:
     1. 19a2d2f
     2. 310afd8

 - #5021: "Please specify a shipping method" Exception (reported by @vphat28) has been fixed in #18689 by @idziakjakub in 2.3-develop branch
   Related commits:
     1. 9688034

 - #13083: OptionManagement.validateOption throws NoSuchEntityException for "0" option label (reported by @rzinnatullin) has been fixed in #18720 by @pmclain in 2.3-develop branch
   Related commits:
     1. ed6a2fb

 - #18357: checkout_agreement_store doesn't exist (reported by @michelecanal) has been fixed in #18412 by @pocallaghan in 2.3-develop branch
   Related commits:
     1. 2bee366

 - #17485: Adding billing information via mine API expects costumer id (reported by @wittyvishwas) has been fixed in #18704 by @pmclain in 2.3-develop branch
   Related commits:
     1. 7584f71

 - #17744: Virtual-only quotes use default shipping address for estimation instead of default billing address (reported by @navarr) has been fixed in #18095 by @LucasCalazans in 2.3-develop branch
   Related commits:
     1. a44eb5d
     2. 0890139
     3. 5372c7d
     4. b871ea9
     5. ec5d9b7
     6. a862620
     7. f3bad34

 - #17865: import new products via csv: products are created with empty value when strings are too long (reported by @LouNik1984) has been fixed in #18639 by @ravi-chandra3197 in 2.3-develop branch
   Related commits:
     1. 499cdd7
     2. a9bc411
     3. b65b49f
     4. 5790225

 - #10205: REST API /V1/products/attributes does not update all properties (reported by @sazzle2611) has been fixed in #18622 by @lewisvoncken in 2.3-develop branch
   Related commits:
     1. 42ecb9c

 - #18268: M2.2.6 : Special price of 0.0000 is not shown on frontend, but is calculated in cart (reported by @kanduvisla) has been fixed in #18631 by @maheshWebkul721 in 2.3-develop branch
   Related commits:
     1. e30a12e

 - #18775: Product Advanced Pricing design issue (reported by @saphaljha) has been fixed in #18790 by @ashutoshwebkul in 2.3-develop branch
   Related commits:
     1. 6bb8258

 - #12300: SKU values are not trimmed with the space. (reported by @ShaileshChauhan92) has been fixed in #18019 by @bartoszkubicki in 2.3-develop branch
   Related commits:
     1. 6c168dd

 - #16572: Trim whitespace on SKU when saving product (reported by @Zyles) has been fixed in #18019 by @bartoszkubicki in 2.3-develop branch
   Related commits:
     1. 6c168dd
  • Loading branch information
Stanislav Idolov authored Oct 27, 2018
2 parents eb27ac2 + 413e489 commit 77af5d6
Show file tree
Hide file tree
Showing 70 changed files with 361 additions and 139 deletions.
3 changes: 3 additions & 0 deletions app/code/Magento/Analytics/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<source_model>Magento\Analytics\Model\Config\Source\Vertical</source_model>
<backend_model>Magento\Analytics\Model\Config\Backend\Vertical</backend_model>
<frontend_model>Magento\Analytics\Block\Adminhtml\System\Config\Vertical</frontend_model>
<depends>
<field id="analytics/general/enabled">1</field>
</depends>
</field>
<field id="additional_comment" translate="label comment" type="label" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
<label><![CDATA[<strong>Get more insights from Magento Business Intelligence</strong>]]></label>
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Catalog/Block/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
namespace Magento\Catalog\Block\Product;

/**
* Product image block
*
* @api
* @method string getImageUrl()
* @method string getWidth()
* @method string getHeight()
* @method string getLabel()
* @method float getRatio()
* @method string getCustomAttributes()
* @method string getClass()
* @since 100.0.2
*/
class Image extends \Magento\Framework\View\Element\Template
Expand Down
24 changes: 20 additions & 4 deletions app/code/Magento/Catalog/Block/Product/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,29 @@ private function getStringCustomAttributes(array $attributes): string
{
$result = [];
foreach ($attributes as $name => $value) {
$result[] = $name . '="' . $value . '"';
if ($name != 'class') {
$result[] = $name . '="' . $value . '"';
}
}
return !empty($result) ? implode(' ', $result) : '';
}

/**
* Retrieve image class for HTML element
*
* @param array $attributes
* @return string
*/
private function getClass(array $attributes): string
{
return $attributes['class'] ?? 'product-image-photo';
}

/**
* Calculate image ratio
*
* @param $width
* @param $height
* @param int $width
* @param int $height
* @return float
*/
private function getRatio(int $width, int $height): float
Expand All @@ -98,8 +111,9 @@ private function getRatio(int $width, int $height): float
}

/**
* @param Product $product
* Get image label
*
* @param Product $product
* @param string $imageType
* @return string
*/
Expand All @@ -114,6 +128,7 @@ private function getLabel(Product $product, string $imageType): string

/**
* Create image block from product
*
* @param Product $product
* @param string $imageId
* @param array|null $attributes
Expand Down Expand Up @@ -154,6 +169,7 @@ public function create(Product $product, string $imageId, array $attributes = nu
'label' => $this->getLabel($product, $imageMiscParams['image_type']),
'ratio' => $this->getRatio($imageMiscParams['image_width'], $imageMiscParams['image_height']),
'custom_attributes' => $this->getStringCustomAttributes($attributes),
'class' => $this->getClass($attributes),
'product_id' => $product->getId()
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ProductCategoryCondition implements CustomConditionInterface

/**
* @param \Magento\Framework\App\ResourceConnection $resourceConnection
* @param \Magento\Catalog\Model\CategoryRepository $categoryRepository
*/
public function __construct(
\Magento\Framework\App\ResourceConnection $resourceConnection,
Expand Down Expand Up @@ -104,7 +105,7 @@ private function getCategoryIds(Filter $filter): array
}
}

return array_unique(array_merge($categoryIds, ...$childCategoryIds));
return array_map('intval', array_unique(array_merge($categoryIds, ...$childCategoryIds)));
}

/**
Expand Down
24 changes: 19 additions & 5 deletions app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
* See COPYING.txt for license details.
*/

/**
* Catalog product SKU backend attribute model
*
* @author Magento Core Team <core@magentocommerce.com>
*/
namespace Magento\Catalog\Model\Product\Attribute\Backend;

use Magento\Catalog\Model\Product;

/**
* Catalog product SKU backend attribute model.
*/
class Sku extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
{
/**
Expand Down Expand Up @@ -97,6 +95,7 @@ protected function _generateUniqueSku($object)
public function beforeSave($object)
{
$this->_generateUniqueSku($object);
$this->trimValue($object);
return parent::beforeSave($object);
}

Expand Down Expand Up @@ -127,4 +126,19 @@ protected function _getLastSimilarAttributeValueIncrement($attribute, $object)
$data = $connection->fetchOne($select, $bind);
return abs((int)str_replace($value, '', $data));
}

/**
* Remove extra spaces from attribute value before save.
*
* @param Product $object
* @return void
*/
private function trimValue($object)
{
$attrCode = $this->getAttribute()->getAttributeCode();
$value = $object->getData($attrCode);
if ($value) {
$object->setData($attrCode, trim($value));
}
}
}
24 changes: 13 additions & 11 deletions app/code/Magento/Catalog/Model/Product/Attribute/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Magento\Framework\Exception\NoSuchEntityException;

/**
* Product attribute repository
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInterface
Expand Down Expand Up @@ -78,7 +80,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function get($attributeCode)
{
Expand All @@ -89,7 +91,7 @@ public function get($attributeCode)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
{
Expand All @@ -100,12 +102,17 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
}

/**
* {@inheritdoc}
* @inheritdoc
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attribute)
{
$attribute->setEntityTypeId(
$this->eavConfig
->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE)
->getId()
);
if ($attribute->getAttributeId()) {
$existingModel = $this->get($attribute->getAttributeCode());

Expand Down Expand Up @@ -144,11 +151,6 @@ public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attrib
$attribute->setBackendModel(
$this->productHelper->getAttributeBackendModelByInputType($attribute->getFrontendInput())
);
$attribute->setEntityTypeId(
$this->eavConfig
->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE)
->getId()
);
$attribute->setIsUserDefined(1);
}
if (!empty($attribute->getData(AttributeInterface::OPTIONS))) {
Expand Down Expand Up @@ -180,7 +182,7 @@ public function save(\Magento\Catalog\Api\Data\ProductAttributeInterface $attrib
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function delete(\Magento\Catalog\Api\Data\ProductAttributeInterface $attribute)
{
Expand All @@ -189,7 +191,7 @@ public function delete(\Magento\Catalog\Api\Data\ProductAttributeInterface $attr
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function deleteById($attributeCode)
{
Expand All @@ -200,7 +202,7 @@ public function deleteById($attributeCode)
}

/**
* {@inheritdoc}
* @inheritdoc
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getCustomAttributesMetadata($dataObjectClassName = null)
Expand Down
5 changes: 4 additions & 1 deletion app/code/Magento/Catalog/Model/ProductCategoryList.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public function getCategoryIds($productId)
Select::SQL_UNION_ALL
);

$this->categoryIdList[$productId] = $this->productResource->getConnection()->fetchCol($unionSelect);
$this->categoryIdList[$productId] = array_map(
'intval',
$this->productResource->getConnection()->fetchCol($unionSelect)
);
}

return $this->categoryIdList[$productId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,8 @@ protected function _productLimitationJoinWebsite()
}
$conditions[] = $this->getConnection()->quoteInto(
'product_website.website_id IN(?)',
$filters['website_ids']
$filters['website_ids'],
'int'
);
} elseif (isset(
$filters['store_id']
Expand All @@ -1821,7 +1822,7 @@ protected function _productLimitationJoinWebsite()
) {
$joinWebsite = true;
$websiteId = $this->_storeManager->getStore($filters['store_id'])->getWebsiteId();
$conditions[] = $this->getConnection()->quoteInto('product_website.website_id = ?', $websiteId);
$conditions[] = $this->getConnection()->quoteInto('product_website.website_id = ?', $websiteId, 'int');
}

$fromPart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::FROM);
Expand Down Expand Up @@ -2017,12 +2018,16 @@ protected function _applyProductLimitations()

$conditions = [
'cat_index.product_id=e.entity_id',
$this->getConnection()->quoteInto('cat_index.store_id=?', $filters['store_id']),
$this->getConnection()->quoteInto('cat_index.store_id=?', $filters['store_id'], 'int'),
];
if (isset($filters['visibility']) && !isset($filters['store_table'])) {
$conditions[] = $this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']);
$conditions[] = $this->getConnection()->quoteInto(
'cat_index.visibility IN(?)',
$filters['visibility'],
'int'
);
}
$conditions[] = $this->getConnection()->quoteInto('cat_index.category_id=?', $filters['category_id']);
$conditions[] = $this->getConnection()->quoteInto('cat_index.category_id=?', $filters['category_id'], 'int');
if (isset($filters['category_is_anchor'])) {
$conditions[] = $this->getConnection()->quoteInto('cat_index.is_parent=?', $filters['category_is_anchor']);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Pricing/Price/BasePrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getValue()
$this->value = false;
foreach ($this->priceInfo->getPrices() as $price) {
if ($price instanceof BasePriceProviderInterface && $price->getValue() !== false) {
$this->value = min($price->getValue(), $this->value ?: $price->getValue());
$this->value = min($price->getValue(), $this->value !== false ? $this->value: $price->getValue());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ private function getTestDataWithoutAttributes(): array
'label' => 'test_image_label',
'ratio' => 1,
'custom_attributes' => '',
'product_id' => null
'product_id' => null,
'class' => 'product-image-photo'
],
],
];
Expand Down Expand Up @@ -190,6 +191,7 @@ private function getTestDataWithAttributes(): array
'custom_attributes' => [
'name_1' => 'value_1',
'name_2' => 'value_2',
'class' => 'my-class'
],
],
'expected' => [
Expand All @@ -201,7 +203,8 @@ private function getTestDataWithAttributes(): array
'label' => 'test_product_name',
'ratio' => 0.5, // <==
'custom_attributes' => 'name_1="value_1" name_2="value_2"',
'product_id' => null
'product_id' => null,
'class' => 'my-class'
],
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ public function __construct(
}

/**
* {@inheritdoc}
* Customize number fields for advanced price and weight fields.
*
* @since 101.0.0
* @param array $data
* @return array
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function modifyData(array $data)
Expand Down Expand Up @@ -130,8 +133,11 @@ protected function customizeAdvancedPriceFormat(array $data)
}

/**
* {@inheritdoc}
* Customize product form fields.
*
* @since 101.0.0
* @param array $meta
* @return array
*/
public function modifyMeta(array $meta)
{
Expand Down Expand Up @@ -361,7 +367,8 @@ protected function customizeNameListeners(array $meta)
$skuPath . static::META_CONFIG_PATH,
$meta,
[
'autoImportIfEmpty' => true
'autoImportIfEmpty' => true,
'validation' => ['no-marginal-whitespace' => true]
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/;
*/
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
style="width:<?= /* @escapeNotVerified */ $block->getWidth() ?>px;">
<span class="product-image-wrapper"
style="padding-bottom: <?= /* @escapeNotVerified */ ($block->getRatio() * 100) ?>%;">
<img class="product-image-photo"
<img class="<?= /* @escapeNotVerified */ $block->getClass() ?>"
<?= /* @escapeNotVerified */ $block->getCustomAttributes() ?>
src="<?= /* @escapeNotVerified */ $block->getImageUrl() ?>"
max-width="<?= /* @escapeNotVerified */ $block->getWidth() ?>"
Expand Down
Loading

0 comments on commit 77af5d6

Please sign in to comment.