init
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Stemcell\Customer\Ui\Component\DataProvider;
|
||||
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
use Magento\Customer\Model\ResourceModel\Customer\Collection;
|
||||
|
||||
class VendorOption implements OptionSourceInterface
|
||||
{
|
||||
private Collection $collection;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $customerTree;
|
||||
|
||||
public function __construct(
|
||||
Collection $collection
|
||||
) {
|
||||
$this->collection = $collection;
|
||||
}
|
||||
|
||||
public function toOptionArray()
|
||||
{
|
||||
|
||||
$collection = $this->collection->addFieldToSelect('firstname');
|
||||
foreach ($collection as $customer) {
|
||||
$customerId = $customer->getEntityId();
|
||||
if (!isset($customerById[$customerId])) {
|
||||
$customerById[$customerId] = [
|
||||
'value' => $customerId
|
||||
];
|
||||
}
|
||||
$customerById[$customerId]['label'] = $customer->getFirstname();
|
||||
}
|
||||
$this->customerTree = $customerById;
|
||||
return $this->customerTree;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user