-
Notifications
You must be signed in to change notification settings - Fork 70
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 #93 from mageplaza/2.4-develop
2.4 develop
- Loading branch information
Showing
13 changed files
with
380 additions
and
192 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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,101 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_BannerSlider | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\BannerSlider\Model\ResourceModel\Slider\Grid; | ||
|
||
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; | ||
use Magento\Framework\Data\Collection\EntityFactoryInterface; | ||
use Magento\Framework\Event\ManagerInterface; | ||
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult; | ||
use Mageplaza\BannerSlider\Model\ResourceModel\Slider; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Class Collection | ||
* @package Mageplaza\BannerSlider\Model\ResourceModel\Slider\Grid | ||
*/ | ||
class Collection extends SearchResult | ||
{ | ||
/** | ||
* ID Field Name | ||
* | ||
* @var string | ||
*/ | ||
protected $_idFieldName = 'slider_id'; | ||
|
||
/** | ||
* Event prefix | ||
* | ||
* @var string | ||
*/ | ||
protected $_eventPrefix = 'mageplaza_bannerslider_slider_collection'; | ||
|
||
/** | ||
* Event object | ||
* | ||
* @var string | ||
*/ | ||
protected $_eventObject = 'slider_collection'; | ||
|
||
/** | ||
* Collection constructor. | ||
* | ||
* @param EntityFactoryInterface $entityFactory | ||
* @param LoggerInterface $logger | ||
* @param FetchStrategyInterface $fetchStrategy | ||
* @param ManagerInterface $eventManager | ||
* @param string $mainTable | ||
* @param string $resourceModel | ||
* | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
public function __construct( | ||
EntityFactoryInterface $entityFactory, | ||
LoggerInterface $logger, | ||
FetchStrategyInterface $fetchStrategy, | ||
ManagerInterface $eventManager, | ||
$mainTable = 'mageplaza_bannerslider_slider', | ||
$resourceModel = Slider::class | ||
) { | ||
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); | ||
} | ||
|
||
/** | ||
* @param array|string $field | ||
* @param null $condition | ||
* | ||
* @return Collection | ||
*/ | ||
public function addFieldToFilter($field, $condition = null) | ||
{ | ||
switch ($field) { | ||
case 'banners': | ||
$field = 'main_table.name'; | ||
break; | ||
case 'customer_group_ids': | ||
return parent::addFieldToFilter('customer_group_ids', ['finset' => $condition['eq']]); | ||
case 'store_ids': | ||
return parent::addFieldToFilter('store_ids', [['finset' => $condition['eq']], ['finset' => 0]]); | ||
} | ||
|
||
return parent::addFieldToFilter($field, $condition); | ||
} | ||
} |
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
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,80 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_BannerSlider | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\BannerSlider\Ui\Component\Listing\Column\CustomerGroup; | ||
|
||
use Magento\Customer\Model\ResourceModel\Group\Collection; | ||
use Magento\Customer\Model\ResourceModel\Group\CollectionFactory; | ||
use Magento\Framework\Data\OptionSourceInterface; | ||
|
||
/** | ||
* Class Options | ||
* @package Mageplaza\BannerSlider\Ui\Component\Listing\Column\CustomerGroup | ||
*/ | ||
class Options implements OptionSourceInterface | ||
{ | ||
/** | ||
* @var CollectionFactory | ||
*/ | ||
protected $_customerGroupColFact; | ||
|
||
/** | ||
* Options constructor. | ||
* | ||
* @param CollectionFactory $customerGroupColFact | ||
*/ | ||
public function __construct(CollectionFactory $customerGroupColFact) | ||
{ | ||
$this->_customerGroupColFact = $customerGroupColFact; | ||
} | ||
|
||
/** | ||
* Get options | ||
* | ||
* @return array | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
return $this->_generateCustomerGroupOptions(); | ||
} | ||
|
||
/** | ||
* Get customer group options | ||
* | ||
* @return array | ||
*/ | ||
protected function _generateCustomerGroupOptions() | ||
{ | ||
$options = []; | ||
$customerGroupCollection = $this->_customerGroupColFact->create(); | ||
|
||
if (count($customerGroupCollection)) { | ||
foreach ($customerGroupCollection as $item) { | ||
$options[] = [ | ||
'label' => $item->getCustomerGroupCode(), | ||
'value' => $item->getCustomerGroupId(), | ||
]; | ||
} | ||
} | ||
|
||
return $options; | ||
} | ||
} |
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
Oops, something went wrong.