3

in that product name column I want to display product name

I want to display product name in that column

5
  • product name in your database table or not? Feb 14, 2019 at 9:06
  • no i have entity_id through that i want to display product name using join query Feb 14, 2019 at 9:07
  • Are you using UI component?
    – Amit Bera
    Feb 14, 2019 at 9:10
  • yes UI component through that product name column is coming Feb 14, 2019 at 9:10
  • You can please provide me Dataprovider class
    – Amit Bera
    Feb 14, 2019 at 9:30

1 Answer 1

0

You have to create a Collection Class which is replicated of current collection class.

Then you have to use a new collection class as the data provider class for ui listing.

Then on protected function _initSelect() of collection, you need to add catalog_product_entity_varchar table list

/**
 * @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface
 */
private $productAttributeRepository;

public function __construct(
 \Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository      
) {

    $this->productAttributeRepository = $productAttributeRepository;
}
private function getAttributeId(){
    $attribute = $this->productAttributeRepository->get('name');
    return $attribute->getAttributeId();
}
protected function _joinFields()
{
    $nameTable = $this->_resource->getTableName('catalog_product_entity_varchar');

    $this->getSelect()->joinLeft(
    array('cpev' => $nameTable), 
        'cpev.entity_id=prod.entity_id AND cpev.attribute_id='.$this->getAttributeId().'', 
        array('name' => 'value')
    );
    return $this;
}
9
  • where I have to put this code please provide a folder structure Feb 14, 2019 at 9:41
  • Please giev data provide code which maintain at dataProvider class=" at ui xml file
    – Amit Bera
    Feb 14, 2019 at 10:01
  • <column name="name"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="filter" xsi:type="string">text</item> <item name="label" translate="true" xsi:type="string">product name</item> <item name="editor" xsi:type="array"> <item name="editorType" xsi:type="string">text</item> <item name="validation" xsi:type="array"> <item name="required-entry" xsi:type="boolean">false</item> </item> </item> </item> </argument> </column> Feb 14, 2019 at 10:03
  • NO. there will be some tag like` <dataProvider>`.I need tag s code
    – Amit Bera
    Feb 14, 2019 at 10:17
  • in which file it is written Feb 14, 2019 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.