init
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Model\Source;
|
||||
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class BooleanOptions implements OptionSourceInterface
|
||||
{
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
return [
|
||||
['value' => '1', 'label' => __('Yes')],
|
||||
['value' => '0', 'label' => __('No')],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Model\Source;
|
||||
|
||||
use Esun\Catalog\Model\ResourceModel\SpecificationBrand\CollectionFactory;
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class SpecificationBrandOptions implements OptionSourceInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CollectionFactory $collectionFactory
|
||||
) {
|
||||
}
|
||||
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
$options = [['value' => '', 'label' => __('Select a brand')]];
|
||||
$collection = $this->collectionFactory->create()
|
||||
->addFieldToFilter('status', 1)
|
||||
->setOrder('sort_order', 'ASC')
|
||||
->setOrder('brand_name', 'ASC');
|
||||
|
||||
foreach ($collection as $brand) {
|
||||
$options[] = [
|
||||
'value' => (string)$brand->getId(),
|
||||
'label' => (string)$brand->getData('brand_name'),
|
||||
];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user