-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from magento-troll/MAGETWO-42140
[Troll] MAGETWO-42140 Category page update
- Loading branch information
Showing
125 changed files
with
3,590 additions
and
2,231 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
app/code/Magento/Catalog/Block/Adminhtml/Category/AssignProducts.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Block\Adminhtml\Category; | ||
|
||
class AssignProducts extends \Magento\Backend\Block\Template | ||
{ | ||
/** | ||
* Block template | ||
* | ||
* @var string | ||
*/ | ||
protected $_template = 'catalog/category/edit/assign_products.phtml'; | ||
|
||
/** | ||
* @var \Magento\Catalog\Block\Adminhtml\Category\Tab\Product | ||
*/ | ||
protected $blockGrid; | ||
|
||
/** | ||
* @var \Magento\Framework\Registry | ||
*/ | ||
protected $registry; | ||
|
||
/** | ||
* @var \Magento\Framework\Json\EncoderInterface | ||
*/ | ||
protected $jsonEncoder; | ||
|
||
/** | ||
* AssignProducts constructor. | ||
* | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Framework\Registry $registry | ||
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Registry $registry, | ||
\Magento\Framework\Json\EncoderInterface $jsonEncoder, | ||
array $data = [] | ||
) { | ||
$this->registry = $registry; | ||
$this->jsonEncoder = $jsonEncoder; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* Retrieve instance of grid block | ||
* | ||
* @return \Magento\Framework\View\Element\BlockInterface | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
public function getBlockGrid() | ||
{ | ||
if (null === $this->blockGrid) { | ||
$this->blockGrid = $this->getLayout()->createBlock( | ||
'Magento\Catalog\Block\Adminhtml\Category\Tab\Product', | ||
'category.product.grid' | ||
); | ||
} | ||
return $this->blockGrid; | ||
} | ||
|
||
/** | ||
* Return HTML of grid block | ||
* | ||
* @return string | ||
*/ | ||
public function getGridHtml() | ||
{ | ||
return $this->getBlockGrid()->toHtml(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getProductsJson() | ||
{ | ||
$products = $this->getCategory()->getProductsPosition(); | ||
if (!empty($products)) { | ||
return $this->jsonEncoder->encode($products); | ||
} | ||
return '{}'; | ||
} | ||
/** | ||
* Retrieve current category instance | ||
* | ||
* @return array|null | ||
*/ | ||
public function getCategory() | ||
{ | ||
return $this->registry->registry('category'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/code/Magento/Catalog/Block/Adminhtml/Category/Edit/DeleteButton.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Block\Adminhtml\Category\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
use Magento\Catalog\Block\Adminhtml\Category\AbstractCategory; | ||
|
||
/** | ||
* Class DeleteButton | ||
*/ | ||
class DeleteButton extends AbstractCategory implements ButtonProviderInterface | ||
{ | ||
/** | ||
* Delete button | ||
* | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
$category = $this->getCategory(); | ||
$categoryId = (int)$category->getId(); | ||
|
||
if ($categoryId && !in_array($categoryId, $this->getRootIds()) && $category->isDeleteable()) { | ||
return [ | ||
'id' => 'delete', | ||
'label' => __('Delete'), | ||
'on_click' => "categoryDelete('" . $this->getDeleteUrl() . "')", | ||
'class' => 'delete', | ||
'sort_order' => 10 | ||
]; | ||
} | ||
|
||
return []; | ||
} | ||
|
||
/** | ||
* @param array $args | ||
* @return string | ||
*/ | ||
public function getDeleteUrl(array $args = []) | ||
{ | ||
$params = array_merge($this->getDefaultUrlParams(), $args); | ||
return $this->getUrl('catalog/*/delete', $params); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
protected function getDefaultUrlParams() | ||
{ | ||
return ['_current' => true, '_query' => ['isAjax' => null]]; | ||
} | ||
} |
Oops, something went wrong.