This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,80 @@
<?php
namespace WeltPixel\Backend\Plugin\Category;
use Magento\Eav\Model\Config;
use Magento\Framework\App\Request\Http as HttpRequest;
class DataProvider
{
/**
* @var Config
*/
private $eavConfig;
/**
* @var HttpRequest
*/
private $request;
/**
* DataProvider constructor.
* @param Config $eavConfig
* @param HttpRequest $request
*/
public function __construct(
Config $eavConfig,
HttpRequest $request
) {
$this->eavConfig = $eavConfig;
$this->request = $request;
}
/**
* @param \Magento\Catalog\Model\Category\DataProvider $subject
* @param array $result
* @return array
*/
public function afterPrepareMeta(\Magento\Catalog\Model\Category\DataProvider $subject, $result)
{
$fullActionName = $this->request->getFullActionName();
if ($fullActionName == 'catalog_category_edit') {
$result = array_merge_recursive($result, $this->_prepareFieldsMeta(
$result,
$this->_getFieldsMap(),
$subject->getAttributesMeta($this->eavConfig->getEntityType('catalog_category'))
));
}
return $result;
}
/**
* Prepare fields meta based on xml declaration of form and fields metadata
*
* @param array $originalResult
* @param array $fieldsMap
* @param array $fieldsMeta
* @return array
*/
protected function _prepareFieldsMeta($originalResult, $fieldsMap, $fieldsMeta)
{
$result = [];
foreach ($fieldsMap as $fieldSet => $fields) {
foreach ($fields as $field) {
if (isset($fieldsMeta[$field]) && (!isset($originalResult[$fieldSet]['children'][$field]))) {
$result[$fieldSet]['children'][$field]['arguments']['data']['config'] = $fieldsMeta[$field];
}
}
}
return $result;
}
/**
* Rewrite this in all subclassess, provide the list with category attributes
* @return array
*/
protected function _getFieldsMap()
{
return [];
}
}
@@ -0,0 +1,17 @@
<?php
namespace WeltPixel\Backend\Plugin\CategoryStaging;
class DataProvider
{
/**
* @param \Magento\Catalog\Model\Category\DataProvider $subject
* @param array $result
* @return array
*/
public function afterPrepareMeta(\Magento\Catalog\Model\Category\DataProvider $subject, $result)
{
unset($result['weltpixel_options']);
unset($result['weltpixel_megamenu']);
return $result;
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace WeltPixel\Backend\Plugin;
use Magento\Framework\App\Config\ScopeConfigInterface;
class ScopeConfig
{
public function afterIsSetFlag(
ScopeConfigInterface $subject,
$result,
$path,
$scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$scopeCode = null
) {
if ($path == 'csp/mode/storefront/report_only') {
if ($subject->getValue('weltpixel_backend_developer/csp/change_system_value')) {
$result = (boolean) $subject->getValue('weltpixel_backend_developer/csp/report_only');
}
}
return $result;
}
public function afterGetValue(
ScopeConfigInterface $subject,
$result,
$path,
$scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$scopeCode = null
) {
if (preg_match('/^csp\/mode\/storefront_[^\/]+\/report_only$/', $path)) {
if ($subject->getValue('weltpixel_backend_developer/csp/change_system_value')) {
$result = (boolean) $subject->getValue('weltpixel_backend_developer/csp/report_only');
}
}
return $result;
}
}