-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Admin panel navigation improvement #33824
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
base: 2.4-develop
Are you sure you want to change the base?
Changes from 1 commit
fb74c69
f54f3e1
f74a90b
b49acde
16348ae
37560d1
a9770b4
a38abcb
c7e6b0d
e6e8645
247aac5
829ba8c
a354516
a9563a2
a815ef1
335ccd5
7b252c7
36763ad
91fb6dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Ui\DataProvider\Product\Modifier; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Magento\Store\Api\Data\StoreInterface; | ||
use Magento\Framework\Escaper; | ||
use Magento\Framework\UrlInterface; | ||
use Magento\Framework\App\Request\Http; | ||
use Magento\Ui\DataProvider\Modifier\ModifierInterface; | ||
|
||
/** | ||
* Modify product listing price attributes | ||
*/ | ||
class AddUrlToName implements ModifierInterface | ||
{ | ||
/** | ||
* @var UrlInterface | ||
*/ | ||
private $urlBuilder; | ||
|
||
/** | ||
* @var Escaper | ||
*/ | ||
private $escaper; | ||
|
||
/** | ||
* @var Http | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* AddUrlToName constructor. | ||
* | ||
* @param UrlInterface $urlBuilder | ||
* @param Escaper $escaper | ||
* @param Http $request | ||
* @param StoreManagerInterface $storeManager | ||
*/ | ||
public function __construct( | ||
UrlInterface $urlBuilder, | ||
Escaper $escaper, | ||
Http $request, | ||
StoreManagerInterface $storeManager | ||
) { | ||
$this->urlBuilder = $urlBuilder; | ||
$this->escaper = $escaper; | ||
$this->request = $request; | ||
$this->storeManager = $storeManager; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function modifyData(array $data): array | ||
{ | ||
if (empty($data)) { | ||
return $data; | ||
} | ||
|
||
$storeId = $this->getStore()->getId(); | ||
|
||
if (!empty($data['items'])) { | ||
foreach ($data['items'] as &$item) { | ||
$url = $this->urlBuilder->getUrl( | ||
'catalog/product/edit', | ||
['id' => $item['entity_id'], 'store' => $storeId] | ||
); | ||
$item['name'] = '<a href="javascript:;" onclick="window.open(\'' . $url . '\', \'_blank\');">' | ||
. $this->escaper->escapeHtml( | ||
$item['name'] | ||
) . '</a>'; | ||
} | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function modifyMeta(array $meta): array | ||
{ | ||
return $meta; | ||
} | ||
|
||
/** | ||
* Retrieve store | ||
* | ||
* @return StoreInterface | ||
* @throws NoSuchEntityException | ||
*/ | ||
private function getStore(): StoreInterface | ||
{ | ||
return $this->storeManager->getStore(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\ConfigurableProduct\Ui\DataProvider\Product; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing - declare(strict_types=1); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by adding declare(strict_types=1); |
||
|
||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; | ||
use Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider; | ||
use Magento\Ui\DataProvider\Modifier\PoolInterface; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing class DOCBLOCK There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by adding DOCBLOCK |
||
class ConfigurableDataProvider extends ProductDataProvider | ||
{ | ||
/** | ||
* Construct | ||
* | ||
* @param string $name | ||
* @param string $primaryFieldName | ||
* @param string $requestFieldName | ||
* @param CollectionFactory $collectionFactory | ||
* @param \Magento\Ui\DataProvider\AddFieldToCollectionInterface[] $addFieldStrategies | ||
* @param \Magento\Ui\DataProvider\AddFilterToCollectionInterface[] $addFilterStrategies | ||
* @param array $meta | ||
* @param array $data | ||
* @param PoolInterface|null $modifiersPool | ||
*/ | ||
public function __construct( | ||
$name, | ||
$primaryFieldName, | ||
$requestFieldName, | ||
CollectionFactory $collectionFactory, | ||
array $meta = [], | ||
array $data = [], | ||
array $addFieldStrategies = [], | ||
array $addFilterStrategies = [], | ||
PoolInterface $modifiersPool = null | ||
) { | ||
parent::__construct( | ||
$name, | ||
$primaryFieldName, | ||
$requestFieldName, | ||
$collectionFactory, | ||
$addFieldStrategies, | ||
$addFilterStrategies, | ||
$meta, | ||
$data, | ||
$modifiersPool | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
use Magento\Bundle\Model\Product\Type; | ||
use Magento\Bundle\Api\ProductOptionRepositoryInterface; | ||
use Magento\Catalog\Api\ProductRepositoryInterface; | ||
use Magento\Catalog\Helper\Product\AddUrlToName as NameHelper; | ||
|
||
/** | ||
* Class Bundle customizes Bundle product creation flow | ||
|
@@ -45,24 +46,32 @@ class Composite extends AbstractModifier | |
*/ | ||
protected $productRepository; | ||
|
||
/** | ||
* @var NameHelper | ||
*/ | ||
protected $nameHelper; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be private There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by changing to private |
||
|
||
/** | ||
* @param LocatorInterface $locator | ||
* @param ObjectManagerInterface $objectManager | ||
* @param ProductOptionRepositoryInterface $optionsRepository | ||
* @param ProductRepositoryInterface $productRepository | ||
* @param NameHelper $nameHelper | ||
* @param array $modifiers | ||
*/ | ||
public function __construct( | ||
LocatorInterface $locator, | ||
ObjectManagerInterface $objectManager, | ||
ProductOptionRepositoryInterface $optionsRepository, | ||
ProductRepositoryInterface $productRepository, | ||
NameHelper $nameHelper, | ||
array $modifiers = [] | ||
) { | ||
$this->locator = $locator; | ||
$this->objectManager = $objectManager; | ||
$this->optionsRepository = $optionsRepository; | ||
$this->productRepository = $productRepository; | ||
$this->nameHelper = $nameHelper; | ||
$this->modifiers = $modifiers; | ||
} | ||
|
||
|
@@ -115,7 +124,7 @@ public function modifyData(array $data) | |
'selection_id' => $productLink->getId(), | ||
'option_id' => $productLink->getOptionId(), | ||
'product_id' => $linkedProduct->getId(), | ||
'name' => $linkedProduct->getName(), | ||
'name' => $this->nameHelper->addUrlToName($linkedProduct), | ||
'sku' => $linkedProduct->getSku(), | ||
'is_default' => ($productLink->getIsDefault()) ? '1' : '0', | ||
'selection_price_value' => $productLink->getPrice(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Helper\Product; | ||
|
||
use Magento\Catalog\Api\Data\ProductInterface; | ||
use Magento\Catalog\Model\Locator\LocatorInterface; | ||
use Magento\Framework\Escaper; | ||
use Magento\Framework\UrlInterface; | ||
|
||
/** | ||
* Ads URL to name for Dataprovider form modifiers | ||
*/ | ||
class AddUrlToName | ||
{ | ||
/** | ||
* @var LocatorInterface | ||
*/ | ||
protected $locator; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. class variables should be private There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by changing to private |
||
|
||
/** | ||
* @var UrlInterface | ||
*/ | ||
protected $urlBuilder; | ||
|
||
/** | ||
* @var Escaper | ||
*/ | ||
protected $escaper; | ||
|
||
/** | ||
* AddUrlToName constructor. | ||
* | ||
* @param LocatorInterface $locator | ||
* @param UrlInterface $urlBuilder | ||
* @param Escaper $escaper | ||
*/ | ||
public function __construct( | ||
LocatorInterface $locator, | ||
UrlInterface $urlBuilder, | ||
Escaper $escaper | ||
) { | ||
$this->locator = $locator; | ||
$this->urlBuilder = $urlBuilder; | ||
$this->escaper = $escaper; | ||
} | ||
|
||
/** | ||
* Add url to product name | ||
* | ||
* @param ProductInterface $linkedProduct | ||
* @return string | ||
*/ | ||
public function addUrlToName(ProductInterface $linkedProduct): string | ||
{ | ||
$storeId = $this->locator->getStore()->getId(); | ||
|
||
$url = $this->urlBuilder->getUrl( | ||
'catalog/product/edit', | ||
['id' => $linkedProduct->getId(), 'store' => $storeId] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally one element per line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed by moving to separate lines |
||
); | ||
|
||
return '<a href="javascript:;" onclick="window.open(\'' . $url . '\', \'_blank\');">' | ||
. $this->escaper->escapeHtml( | ||
$linkedProduct->getName() | ||
) . '</a>'; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing copyright notice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by adding copyright notice