init
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Model\Config\Source;
|
||||
|
||||
use Esun\Catalog\Model\ResourceModel\CertificationType\CollectionFactory;
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class CertificationTypeOptions implements OptionSourceInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CollectionFactory $collectionFactory
|
||||
) {
|
||||
}
|
||||
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
$options = [['value' => '', 'label' => __('Select a certification type')]];
|
||||
$collection = $this->collectionFactory->create()
|
||||
->addFieldToFilter('status', 1)
|
||||
->setOrder('sort_order', 'ASC')
|
||||
->setOrder('name', 'ASC');
|
||||
|
||||
foreach ($collection as $type) {
|
||||
$options[] = [
|
||||
'value' => (string)$type->getId(),
|
||||
'label' => (string)$type->getData('name'),
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Model\Config\Source;
|
||||
|
||||
use Magento\Eav\Model\Config as EavConfig;
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class ColorOptionOptions implements OptionSourceInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EavConfig $eavConfig
|
||||
) {
|
||||
}
|
||||
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
$attribute = $this->eavConfig->getAttribute('catalog_product', 'color');
|
||||
$options = [];
|
||||
foreach ($attribute->getSource()->getAllOptions(false) as $option) {
|
||||
$value = (int)($option['value'] ?? 0);
|
||||
if ($value <= 0) {
|
||||
continue;
|
||||
}
|
||||
$options[] = [
|
||||
'value' => $value,
|
||||
'label' => (string)($option['label'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Model\Config\Source;
|
||||
|
||||
use Magento\Customer\Model\Group;
|
||||
use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class MixCustomerGroupOptions implements OptionSourceInterface
|
||||
{
|
||||
public function __construct(private readonly CollectionFactory $collectionFactory)
|
||||
{
|
||||
}
|
||||
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
$options = [
|
||||
['value' => Group::CUST_GROUP_ALL, 'label' => __('ALL GROUPS')],
|
||||
];
|
||||
$collection = $this->collectionFactory->create()->setOrder('customer_group_code', 'ASC');
|
||||
|
||||
foreach ($collection as $group) {
|
||||
$options[] = [
|
||||
'value' => (int)$group->getId(),
|
||||
'label' => (string)$group->getCode(),
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class MixPriceTypeOptions implements OptionSourceInterface
|
||||
{
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
return [
|
||||
['value' => 'percent', 'label' => __('Discount Percentage')],
|
||||
['value' => 'fixed', 'label' => __('Fixed Unit Price')],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Model\Config\Source;
|
||||
|
||||
use Esun\Video\Model\ResourceModel\Video\CollectionFactory;
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class VideoOptions implements OptionSourceInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CollectionFactory $collectionFactory
|
||||
) {
|
||||
}
|
||||
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
$options = [['value' => '', 'label' => __('Select a video')]];
|
||||
|
||||
foreach ($this->collectionFactory->create()->addFieldToFilter('status', 1)->setOrder('video_id', 'DESC') as $video) {
|
||||
$options[] = [
|
||||
'value' => (string)$video->getId(),
|
||||
'label' => sprintf('#%d - %s', (int)$video->getId(), (string)$video->getData('title')),
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user