我是新手Magento2开发者。
我现在正在制作一个小模块而且我被困在一个地方 。
使用建立管理网格 示例,这是我的 di.xml strong>: p>
我还使用带有硬编码列的布局XML文件: p>
我的表有列 喜欢:产品ID,铜 stomer id,price,status p>
我的问题是: p>
< preference for =“Magento \ Catalog \ Model \ Product”type = “Vendor \ Module \ Model \ Product”/>
< virtualType name =“Vendor \ Module \ Model \ ResourceModel \ Grid \ Grid \ Collection”type =“Magento \ Framework \ View \ Element \ UiComponent \ DataProvider \ SearchResult”>
< arguments>
< argument name =“mainTable”xsi:type =“string”> vendor_module< / argument>
< argument name =“resourceModel”xsi:type =“string”> Vendor \ Module \ Model \ ResourceModel \ Grid< / 参数>
< / arguments>
< / virtualType>
< type name =“Magento \ Framework \ View \ Element \ UiComponent \ DataProvider \ CollectionFactory”>
< arguments>
< argument name =“collections”xsi:type =“array”>
< item name =“grid_record_grid_list_data_source”xsi:type =“string”> Vendor \ Module \ Model \ ResourceModel \ Grid \ Grid \ Collection< / item>
< / argument>
< / arguments>
< ; / type>
code> pre>
...
< column name =“customer”>
< argument name =“data”xsi:type =“array”>
< item name =“config”xsi:type =“array”>
< item name =“filter”xsi:type =“string”> false< / item>
< item name =“label”xsi:type =“string”translate =“true”> Customer< / item>
< / item>
< / argument>
< / column>
...
code> pre>
I’m newbie Magento2 developer. Now I’m making one small module and I’m stuck in one place. I built admin grid with founded example and here is my di.xml:
<preference for="Magento\Catalog\Model\Product" type="Vendor\Module\Model\Product" />
<virtualType name="Vendor\Module\Model\ResourceModel\Grid\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">vendor_module</argument>
<argument name="resourceModel" xsi:type="string">Vendor\Module\Model\ResourceModel\Grid</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="grid_record_grid_list_data_source" xsi:type="string">Vendor\Module\Model\ResourceModel\Grid\Grid\Collection</item>
</argument>
</arguments>
</type>
And also I use layout XML file with hardcoded columns inside:
...
<column name="customer" >
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Customer</item>
</item>
</argument>
</column>
...
My table has columns like: product id, customer id, price, status
And my questions are:
- How do I transform customer id to first+last name?
- Column “status” has 3 different states (0, 1 and 2) - how do I convert them to human-readable words? (undefined, good, bad)
- How to add to same grid another column for example $price + 10%?