0

I need to edit configurable product grid view. Dashboard -> Catalog -> Product-> Add product(configurable product) or Edit(configurable product) ->Create Configuration or Edit Configuration -> Grid view.

Here i need to remove sku column and add another column instead of this one.

How to edit these fields. enter image description here

0

2 Answers 2

2

modify grid.php at location

{vendor}{theme}{Magento_Catalog}\Block\Adminhtml\Prduct

Old code

/*some code */

protected function _prepareCollection()
    {
        parent::_prepareCollection();

        $store = $this->_getStore();
        $collection = $this->_productFactory->create()->getCollection()->addAttributeToSelect(
            'sku'
        )->addAttributeToSelect(
            'name'
        )->addAttributeToSelect(
            'attribute_set_id'
        )->addAttributeToSelect(
            'type_id'
        )->setStore(
            $store
        );
/*some code */

New Code

protected function _prepareCollection()
{
parent::_prepareCollection();

$store = $this->_getStore();
$collection = $this->_productFactory->create()->getCollection()->addAttributeToSelect(
    'description'
)->addAttributeToSelect(
    'name'
)->addAttributeToSelect(
    'attribute_set_id'
)->addAttributeToSelect(
    'type_id'
)->setStore(
    $store
);
/*some code */

protected function _prepareColumns(){

/* some code */ 
$this->addColumn(
    'sku',
    [
        'header' => __('SKU'),
        'index' => 'sku'
    ]
);

new code

protected function _prepareColumns(){
/* some code */ 
$this->addColumn(
    'description',
    [
        'header' => __('Descrption'),
        'index' => 'description'
    ]
);

Hope this will help you

3
  • Thanks for the answer. But it didn't works for me. I need to add attribute column to the product detail page. Not to the main grid.
    – Rita Jose
    Apr 19, 2017 at 12:33
  • If this answer work please approve it. Apr 19, 2017 at 12:34
  • it doesn't work for me
    – Rita Jose
    Apr 20, 2017 at 4:03
0

Step 1: in

Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\ConfigurablePane page,on

protected function getRows()
{
}
remove 'sku_container' => $this->getColumn('sku', __('SKU')),

and add

'oem_sku_container' => $this->getColumn('oem_sku', __('OEMSKU')),
                    'internal_sku_container' => $this->getColumn('internal_sku', __('INTERNALSKU')),

Step:2

In this page, Magento\Ui\Component\Form

on

 public function getDataSourceData()
    {
  $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $product = $objectManager->get('Magento\Framework\Registry')->registry('current_product');//get current product
        $type_id =   $product->getTypeId();
        if($type_id ==  'configurable'){
            foreach ($data as $key_id => $data_value) {
                if (array_key_exists('configurable-matrix', $data_value)) {

foreach ($data_value['configurable-matrix'] as $configurableMatrixKey => $configurableMatrix) 
{
                        $sam_pid    =   $configurableMatrix['id'];
                        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

                        $productObj = $objectManager->get('Magento\Catalog\Model\Product')
                        ->load($sam_pid);

                        $product_oem_sku = $productObj->getOemSku();
                        $product_internal_sku = $productObj->getInternalSku();

                        $data[$key_id]['configurable-matrix'][$configurableMatrixKey]['oem_sku']      = $product_oem_sku;
                        $data[$key_id]['configurable-matrix'][$configurableMatrixKey]['internal_sku'] = $product_internal_sku;
                    }
                }
            }
        } 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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