init
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace Stemcell\ChineseDirectory\Model\Entity\Attribute\Backend;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class City extends AbstractBackend
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function beforeSave($object)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Stemcell\ChineseDirectory\Model\Entity\Attribute\Backend;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
|
||||
use Stemcell\ChineseDirectory\Model\CollectionFactory;
|
||||
|
||||
class District extends AbstractBackend
|
||||
{
|
||||
protected CollectionFactory $collectionFactory;
|
||||
|
||||
public function __construct(
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
}
|
||||
|
||||
public function beforeSave($object)
|
||||
{
|
||||
if (is_numeric($object->getData('district_code'))) {
|
||||
$district = $this->collectionFactory->create('district')
|
||||
->addFieldToFilter('code', $object->getData('district_code'))
|
||||
->getFirstItem();
|
||||
$object->setData('district', $district->getData('name'));
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Stemcell\ChineseDirectory\Model\Entity\Attribute\Backend;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
|
||||
use Stemcell\ChineseDirectory\Model\CollectionFactory;
|
||||
|
||||
class DistrictCode extends AbstractBackend
|
||||
{
|
||||
protected CollectionFactory $collectionFactory;
|
||||
|
||||
public function __construct(
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
}
|
||||
|
||||
public function beforeSave($object)
|
||||
{
|
||||
if (is_numeric($object->getData('district_code'))) {
|
||||
$object->setData('district_code', $object->getData('district_code'));
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Stemcell\ChineseDirectory\Model\Entity\Attribute\Backend;
|
||||
|
||||
use Stemcell\ChineseDirectory\Model\CollectionFactory;
|
||||
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
|
||||
|
||||
class Town extends AbstractBackend
|
||||
{
|
||||
protected CollectionFactory $collectionFactory;
|
||||
|
||||
public function __construct(
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
}
|
||||
|
||||
public function beforeSave($object)
|
||||
{
|
||||
if (is_numeric($object->getData('town_code'))) {
|
||||
$district = $this->collectionFactory->create('town')
|
||||
->addFieldToFilter('code', $object->getData('town_code'))
|
||||
->getFirstItem();
|
||||
$object->setData('town', $district->getData('name'));
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Stemcell\ChineseDirectory\Model\Entity\Attribute\Source;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class CityId extends AbstractSource
|
||||
{
|
||||
public function getAllOptions()
|
||||
{
|
||||
return $this->_options = [
|
||||
['value' => '', 'label' => __('Please select a city.')]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Stemcell\ChineseDirectory\Model\Entity\Attribute\Source;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class DistrictId extends AbstractSource
|
||||
{
|
||||
public function getAllOptions()
|
||||
{
|
||||
return $this->_options = [
|
||||
['value' => '', 'label' => __('Please select a district.')]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Stemcell\ChineseDirectory\Model\Entity\Attribute\Source;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class TownId extends AbstractSource
|
||||
{
|
||||
public function getAllOptions()
|
||||
{
|
||||
return $this->_options = [
|
||||
['value' => '', 'label' => __('Please select street.')]
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user