我想在管理网格中查看extension_attributes的值
下面是我尝试过的代码:
extension_attribtues.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Quote\Api\Data\CartInterface">
<attribute code="store_capacity" type="string"/>
</extension_attributes>
</config>
Plugin.php中的afterGet():它会将Quotes中的storeCapacity表保存起来,stoeCapacity是一个包含其他字段的表。
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$rr = $objectManager->create('Namespace\Module\Model\ResourceModel\Modulename\Collection');
$storeCapacity = $rr
->addFieldToSelect('*')
->addFieldToFilter('id', $entity->getId())
->getItems();
$extensionAttributes = $entity->getExtensionAttributes();
$extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->_extensionFactory->create();
if (sizeof($storeCapacity) > 0)
{
$extensionAttributes->setStoreCapacity($storeCapacity);
}
$subject->save($entity);
return $entity
现在,我想在我创建的Namespace \ Module \ Ui \ Component \ Listing \ Column \ Capacity的Listing.xml中获取它,以获取storeCapacity的字段,但是一旦我编写了prepareDataSource的功能,错误。
您能建议我该如何跟进吗?