Skip to content

Commit

Permalink
Merge branch '2.4-develop' into fix-24357
Browse files Browse the repository at this point in the history
  • Loading branch information
tnsezer authored Dec 16, 2019
2 parents 49738bd + c7a2450 commit d0006b9
Show file tree
Hide file tree
Showing 181 changed files with 8,165 additions and 2,468 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<field id="search_suggestion_enabled">1</field>
</depends>
</field>
<field id="search_suggestion_count_results_enabled" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="search_suggestion_count_results_enabled" translate="label comment" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Show Results Count for Each Suggestion</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>When you enable this option your site may slow down.</comment>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<frontend_model>Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel</frontend_model>
<backend_model>Magento\Analytics\Model\Config\Backend\CollectionTime</backend_model>
</field>
<field id="vertical" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="vertical" translate="hint label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<hint>Industry Data</hint>
<label>Industry</label>
<comment>In order to personalize your Advanced Reporting experience, please select your industry.</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<actionsColumn name="actions" class="\Magento\AsynchronousOperations\Ui\Component\Listing\Column\Actions">
<settings>
<indexField>id</indexField>
<label>Action</label>
<label translate="true">Action</label>
</settings>
</actionsColumn>
</columns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;

use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Config\Model\Config\Source\Yesno;
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
use Magento\Eav\Helper\Data;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Stdlib\DateTime;

/**
* Product attribute add/edit form main tab
* Product attribute add/edit advanced form tab
*
* @api
* @since 100.0.2
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Advanced extends Generic
{
Expand Down Expand Up @@ -70,7 +74,7 @@ public function __construct(
* Adding product form elements for editing attribute
*
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
* @throws LocalizedException
* @SuppressWarnings(PHPMD)
*/
protected function _prepareForm()
Expand Down Expand Up @@ -139,7 +143,21 @@ protected function _prepareForm()
'label' => __('Default Value'),
'title' => __('Default Value'),
'value' => $attributeObject->getDefaultValue(),
'date_format' => $dateFormat
'date_format' => $dateFormat,
]
);

$timeFormat = $this->_localeDate->getTimeFormat(\IntlDateFormatter::SHORT);
$fieldset->addField(
'default_value_datetime',
'date',
[
'name' => 'default_value_datetime',
'label' => __('Default Value'),
'title' => __('Default Value'),
'value' => $this->getLocalizedDateDefaultValue(),
'date_format' => $dateFormat,
'time_format' => $timeFormat,
]
);

Expand Down Expand Up @@ -266,7 +284,7 @@ protected function _initFormValues()
/**
* Retrieve attribute object from registry
*
* @return mixed
* @return Attribute
*/
private function getAttributeObject()
{
Expand All @@ -285,4 +303,28 @@ private function getPropertyLocker()
}
return $this->propertyLocker;
}

/**
* Get localized date default value
*
* @return string
* @throws LocalizedException
*/
private function getLocalizedDateDefaultValue(): string
{
$attributeObject = $this->getAttributeObject();
if (empty($attributeObject->getDefaultValue()) || $attributeObject->getFrontendInput() !== 'datetime') {
return (string)$attributeObject->getDefaultValue();
}

try {
$localizedDate = $this->_localeDate->date($attributeObject->getDefaultValue(), null, false);
$localizedDate->setTimezone(new \DateTimeZone($this->_localeDate->getConfigTimezone()));
$localizedDate = $localizedDate->format(DateTime::DATETIME_PHP_FORMAT);
} catch (\Exception $e) {
throw new LocalizedException(__('The default date is invalid.'));
}

return $localizedDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,60 @@
/**
* Product attribute add/edit form main tab
*
* @author Magento Core Team <[email protected]>
* @author Magento Core Team <[email protected]>
*/
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;

use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply as HelperApply;
use Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Data\Form\Element\Fieldset;
use Magento\Framework\DataObject;

/**
* Product attribute add/edit form main tab
*
* @api
* @SuppressWarnings(PHPMD.DepthOfInheritance)
* @since 100.0.2
*/
class Main extends AbstractMain
{
/**
* Adding product form elements for editing attribute
*
* @return $this
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
* @inheritdoc
*/
protected function _prepareForm()
{
parent::_prepareForm();
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attributeObject */
$attributeObject = $this->getAttributeObject();
/* @var $form \Magento\Framework\Data\Form */
$form = $this->getForm();
/* @var $fieldset \Magento\Framework\Data\Form\Element\Fieldset */
$fieldset = $form->getElement('base_fieldset');
$fieldsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];

foreach ($fieldset->getElements() as $element) {
/** @var \Magento\Framework\Data\Form\AbstractForm $element */
if (substr($element->getId(), 0, strlen('default_value')) == 'default_value') {
$fieldsToRemove[] = $element->getId();
}
}
foreach ($fieldsToRemove as $id) {
$fieldset->removeField($id);
}
$this->removeUnusedFields();
$this->processFrontendInputTypes();

$this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $this->getForm()]);

return $this;
}

/**
* @inheritdoc
*/
protected function _getAdditionalElementTypes()
{
return ['apply' => HelperApply::class];
}

/**
* Process frontend input types for product attributes
*
* @return void
*/
private function processFrontendInputTypes(): void
{
$form = $this->getForm();
/** @var AbstractElement $frontendInputElm */
$frontendInputElm = $form->getElement('frontend_input');
$additionalTypes = [
['value' => 'price', 'label' => __('Price')],
['value' => 'media_image', 'label' => __('Media Image')],
];
$additionalReadOnlyTypes = ['gallery' => __('Gallery')];
if (isset($additionalReadOnlyTypes[$attributeObject->getFrontendInput()])) {
$additionalTypes[] = [
'value' => $attributeObject->getFrontendInput(),
'label' => $additionalReadOnlyTypes[$attributeObject->getFrontendInput()],
];
}
$additionalTypes = $this->getAdditionalFrontendInputTypes();

$response = new \Magento\Framework\DataObject();
$response = new DataObject();
$response->setTypes([]);
$this->_eventManager->dispatch('adminhtml_product_attribute_types', ['response' => $response]);
$_hiddenFields = [];
Expand All @@ -74,19 +74,51 @@ protected function _prepareForm()

$frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
$frontendInputElm->setValues($frontendInputValues);
}

$this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $form]);
/**
* Get additional Frontend Input Types for product attributes
*
* @return array
*/
private function getAdditionalFrontendInputTypes(): array
{
$additionalTypes = [
['value' => 'price', 'label' => __('Price')],
['value' => 'media_image', 'label' => __('Media Image')],
];

return $this;
$additionalReadOnlyTypes = ['gallery' => __('Gallery')];
$attributeObject = $this->getAttributeObject();
if (isset($additionalReadOnlyTypes[$attributeObject->getFrontendInput()])) {
$additionalTypes[] = [
'value' => $attributeObject->getFrontendInput(),
'label' => $additionalReadOnlyTypes[$attributeObject->getFrontendInput()],
];
}

return $additionalTypes;
}

/**
* Retrieve additional element types for product attributes
* Remove unused form fields
*
* @return array
* @return void
*/
protected function _getAdditionalElementTypes()
private function removeUnusedFields(): void
{
return ['apply' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply::class];
$form = $this->getForm();
/* @var $fieldset Fieldset */
$fieldset = $form->getElement('base_fieldset');
$fieldsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];
foreach ($fieldset->getElements() as $element) {
/** @var AbstractElement $element */
if (substr($element->getId(), 0, strlen('default_value')) === 'default_value') {
$fieldsToRemove[] = $element->getId();
}
}
foreach ($fieldsToRemove as $id) {
$fieldset->removeField($id);
}
}
}
28 changes: 21 additions & 7 deletions app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

/**
* Adminhtml catalog product action attribute update helper
*/
namespace Magento\Catalog\Helper\Product\Edit\Action;

/**
* Class Attribute
* Adminhtml catalog product action attribute update helper.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class Attribute extends \Magento\Backend\Helper\Data
{
Expand All @@ -32,7 +32,7 @@ class Attribute extends \Magento\Backend\Helper\Data
/**
* Excluded from batch update attribute codes
*
* @var string[]
* @var array
*/
protected $_excludedAttributes = ['url_key'];

Expand Down Expand Up @@ -92,6 +92,7 @@ public function __construct(

/**
* Return product collection with selected product filter
*
* Product collection didn't load
*
* @return \Magento\Catalog\Model\ResourceModel\Product\Collection
Expand Down Expand Up @@ -171,8 +172,8 @@ public function getAttributes()
$this->getProductsSetIds()
);

if ($this->_excludedAttributes) {
$this->_attributes->addFieldToFilter('attribute_code', ['nin' => $this->_excludedAttributes]);
if ($excludedAttributes = $this->getExcludedAttributes()) {
$this->_attributes->addFieldToFilter('attribute_code', ['nin' => $excludedAttributes]);
}

// check product type apply to limitation and remove attributes that impossible to change in mass-update
Expand All @@ -193,11 +194,24 @@ public function getAttributes()
}

/**
* Gets website id.
*
* @param int $storeId
* @return int
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getStoreWebsiteId($storeId)
{
return $this->_storeManager->getStore($storeId)->getWebsiteId();
}

/**
* Retrieve excluded attributes.
*
* @return array
*/
public function getExcludedAttributes(): array
{
return $this->_excludedAttributes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</arguments>

<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/>
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingFilters"/>
<fillField selector="{{AdminProductAttributeGridSection.FilterByAttributeCode}}" userInput="{{ProductAttribute.attribute_code}}" stepKey="setAttributeCode"/>
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="searchForAttributeFromTheGrid"/>
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnAttributeRow"/>
Expand Down Expand Up @@ -351,6 +352,23 @@
<fillField stepKey="fillDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueDate}}" userInput="{{date}}"/>
</actionGroup>

<!-- Inputs datetime default value and attribute code-->
<actionGroup name="CreateProductAttributeWithDatetimeField" extends="createProductAttribute" insertAfter="checkRequired">
<annotations>
<description>EXTENDS: createProductAttribute. Fills in the Attribute Code and Default Value (Attribute Type: Date and Time Field).</description>
</annotations>
<arguments>
<argument name="date" type="string"/>
</arguments>

<scrollTo selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="scrollToAdvancedSection"/>
<conditionalClick selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" dependentSelector="{{AdvancedAttributePropertiesSection.AttributeCode}}" visible="false" stepKey="openAdvancedSection"/>
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" stepKey="waitForSlideOutAdvancedSection"/>
<fillField selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" userInput="{{attribute.attribute_code}}" stepKey="fillCode"/>
<scrollTo selector="{{AdvancedAttributePropertiesSection.defaultValueDatetime}}" stepKey="scrollToDefaultField"/>
<fillField selector="{{AdvancedAttributePropertiesSection.defaultValueDatetime}}" userInput="{{date}}" stepKey="fillDefaultValue"/>
</actionGroup>

<!-- Creates dropdown option at row without saving-->
<actionGroup name="createAttributeDropdownNthOption">
<annotations>
Expand All @@ -376,4 +394,15 @@

<checkOption selector="{{AttributePropertiesSection.dropdownNthOptionIsDefault(row)}}" stepKey="setAsDefault" after="fillStoreView"/>
</actionGroup>

<!-- Go to advanced attribute properties -->
<actionGroup name="AdminNavigateToProductAttributeAdvancedSection">
<annotations>
<description>Navigate and open Advanced Attribute Properties section on product attribute page</description>
</annotations>

<scrollTo selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="scrollToSection"/>
<conditionalClick selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" dependentSelector="{{AdvancedAttributePropertiesSection.AttributeCode}}" visible="false" stepKey="openSection"/>
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" stepKey="waitForSlideOutSection"/>
</actionGroup>
</actionGroups>
Loading

0 comments on commit d0006b9

Please sign in to comment.