Я попытался показать страну доставки в сетке заказов на продажу администратора, но ничего не работает.
Я дважды проверил конфигурацию адреса клиента, и там я вижу, что переменная страны существует и должна быть отображена. Но в сетке не видно страны доставки.
Какие-нибудь обходные пути?





Я нашел решение. Создание модуля и перезаписи класса.
приложение / код / поставщик / ExtendedAdminGrid / etc / di.xml
<?xml version = "1.0"?>
<config xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "urn:magento:framework:ObjectManager/etc/config.xsd">
<type name = "Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name = "collections" xsi:type = "array">
<item name = "sales_order_grid_data_source" xsi:type = "string">Vendor\ExtendedAdminGrid\Model\ResourceModel\Order\Grid\Collection</item>
</argument>
</arguments>
</type>
</config>
приложение / код / поставщик / ExtendedAdminGrid / etc / module.xml
<?xml version = "1.0"?>
<config xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "urn:magento:framework:Module/etc/module.xsd">
<module name = "Vendor_ExtendedAdminGrid" setup_version = "2.0.0">
<sequence>
<module name = "Magento_Sales"/>
<module name = "Magento_Backend"/>
</sequence>
</module>
</config>
приложение / код / поставщик / ExtendedAdminGrid / модель / ResourceModel / Order / Grid / Collection.php
<?php
namespace Vendor\ExtendedAdminGrid\Model\ResourceModel\Order\Grid;
class Collection extends \Magento\Sales\Model\ResourceModel\Order\Grid\Collection
{
protected function _renderFiltersBefore()
{
$this->getSelect()->joinLeft(
["soa" => "sales_order_address"],
"main_table.entity_id = soa.parent_id and soa.address_type = 'shipping'",
array('country_id')
)
->distinct();
parent::_renderFiltersBefore();
}
protected function _initSelect()
{
$this->addFilterToMap('created_at', 'main_table.created_at');
$this->addFilterToMap('base_grand_total', 'main_table.base_grand_total');
$this->addFilterToMap('grand_total', 'main_table.grand_total');
$this->addFilterToMap('store_id', 'main_table.store_id');
$this->addFilterToMap('store_name', 'main_table.store_name');
$this->addFilterToMap('order_id', 'main_table.order_id');
$this->addFilterToMap('order_increment_id', 'main_table.order_increment_id');
$this->addFilterToMap('billing_name', 'main_table.billing_name');
$this->addFilterToMap('billing_name', 'main_table.shipping_name');
$this->addFilterToMap('status', 'main_table.status');
parent::_initSelect();
}
}
приложение / код / поставщик / ExtendedAdminGrid / view / adminhtml / ui_component / sales_order_grid.xml
<?xml version = "1.0" encoding = "UTF-8"?>
<listing xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name = "sales_order_columns">
<column name = "country_id">
<argument name = "data" xsi:type = "array">
<item name = "config" xsi:type = "array">
<item name = "filter" xsi:type = "string">text</item>
<item name = "label" xsi:type = "string" translate = "true">Shipping Country ID</item>
</item>
</argument>
</column>
</columns>
</listing>
приложение / код / поставщик / ExtendedAdminGrid / registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_ExtendedAdminGrid',
__DIR__
);
Спасибо Сергею за отличный пост Изменение сетки заказов на продажу magento2 по умолчанию - добавление столбца кода купона.