I have a custom grid using ui component method in back-end to show data from a custom table with columns as follows:

id 
product_id 
user_id 
store_ids 
status 
adminassign 
created 
modified 
position

Here the product_id, user_id, status denotes default Product ID, Customer ID and Product Status respectively. Now I have displayed these values in the custom grid.
How can I join the default catalog_product and customer tables to show more fields like Product Name, Product Image, Product Status and Customer Name in to the grid.

Please help me out. Thank you in advance.

有帮助吗?

解决方案

You can add _initSelect() method in your Collection.php file in your custom module

protected function _initSelect()
{
  parent::_initSelect();
  $this->getSelect()->joinLeft(
    ['cp' => $this->getTable('catalog_product')],
    'main_table.product_id = cp.entity_id',
    ['*']
  );
  return $this;
}

You can check this module as a reference link.

Hope this will help you!

许可以下: CC-BY-SA归因
scroll top