Domanda

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.

È stato utile?

Soluzione

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!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top