ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,72 @@
<?php
namespace JR\NetSuite\Model\Config\Source;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\InventoryApi\Api\SourceRepositoryInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
class InventorySource extends AbstractSource implements SourceInterface, OptionSourceInterface
{
protected $sourceRepository;
protected $searchCriteriaBuilder;
public function __construct(
SourceRepositoryInterface $sourceRepository,
SearchCriteriaBuilder $searchCriteriaBuilder
) {
$this->sourceRepository = $sourceRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
}
/**
* Retrieve option array
*
* @return string[]
*/
public function getOptionArray()
{
$searchCriteria = $this->searchCriteriaBuilder->create();
$sources = $this->sourceRepository->getList($searchCriteria)->getItems();
$options = [];
foreach ($sources as $source) {
$options[$source->getSourceCode()] = $source->getName();
}
return $options;
}
/**
* Get options
*
* @return array
*/
public function getAllOptions()
{
$searchCriteria = $this->searchCriteriaBuilder->create();
$sources = $this->sourceRepository->getList($searchCriteria)->getItems();
$options = [];
foreach ($sources as $source) {
$options[] = [
'value' => $source->getSourceCode(),
'label' => $source->getName()
];
}
return $options;
}
/**
* Retrieve option text by option value
*
* @return array
*/
public function toOptionArray()
{
return $this->getAllOptions();
}
}