Skip to content

Product is being saved even when Special Price From Date is later than To Date using mass action #40132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute;

use Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute as AttributeAction;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute as AttributeAction;
use Magento\Framework\App\ObjectManager;

class Validate extends AttributeAction implements HttpGetActionInterface, HttpPostActionInterface
Expand Down Expand Up @@ -69,6 +70,7 @@ public function execute()
continue;
}
$data->setData($attributeCode, $value);
$this->updateRestrictionsDateRanges($attribute, $attributeCode, $attributesData);
$attribute->getBackend()->validate($data);
}
}
Expand All @@ -91,4 +93,25 @@ public function execute()
}
return $this->resultJsonFactory->create()->setJsonData($response->toJson());
}

/**
* Set restrictions for date ranges
*
* @param Attribute $attribute
* @param string $attributeCode
* @param array $attributesData
* @return void
*/
protected function updateRestrictionsDateRanges(&$attribute, $attributeCode, $attributesData)
{
if ($attributeCode == 'special_from_date' && !empty($attributesData['special_to_date'])) {
$attribute->setMaxValue($attributesData['special_to_date']);
}
if ($attributeCode == 'news_from_date' && !empty($attributesData['news_to_date'])) {
$attribute->setMaxValue($attributesData['news_to_date']);
}
if ($attributeCode == 'custom_design_from' && !empty($attributesData['custom_design_to'])) {
$attribute->setMaxValue($attributesData['custom_design_to']);
}
}
}