1
0
mirror of synced 2024-11-29 00:25:30 +03:00
magento-module/Model/Setting/Shipping.php

51 lines
1.5 KiB
PHP
Raw Normal View History

2017-05-31 15:24:46 +03:00
<?php
namespace Retailcrm\Retailcrm\Model\Setting;
class Shipping implements \Magento\Framework\Option\ArrayInterface
{
2018-03-12 16:34:48 +03:00
protected $_entityType;
protected $_store;
public function __construct(
\Magento\Store\Model\Store $store,
\Magento\Eav\Model\Entity\Type $entityType
) {
$this->_store = $store;
$this->_entityType = $entityType;
}
public function toOptionArray()
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$activeShipping = $objectManager->create('Magento\Shipping\Model\Config')->getActiveCarriers();
$config = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface');
foreach ($activeShipping as $carrierCode => $carrierModel) {
$options = [];
if ($carrierModel->getAllowedMethods()) {
$carrierMethods = $carrierModel->getAllowedMethods();
foreach ($carrierMethods as $methodCode => $method) {
$code = $carrierCode . '_' . $methodCode;
$options[] = [
'value' => $code,
'label' => $method
];
}
$carrierTitle = $config->getValue('carriers/' . $carrierCode . '/title');
}
$methods[] = [
'value' => $options,
'label' => $carrierTitle
];
}
return $methods;
}
}