How to remove products linked to another store view?Magento 2: Can you Filter By store_id Using a Product...

Does "Until when" sound natural for native speakers?

How to draw cubes in a 3 dimensional plane

How did Alan Turing break the enigma code using the hint given by the lady in the bar?

Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?

Can I pump my MTB tire to max (55 psi / 380 kPa) without the tube inside bursting?

Find longest word in a string: are any of these algorithms good?

Dropdown com clique

What wound would be of little consequence to a biped but terrible for a quadruped?

Why would one plane in this picture not have gear down yet?

What are actual Tesla M60 models used by AWS?

Does the nature of the Apocalypse in The Umbrella Academy change from the first to the last episode?

Why doesn't this Google Translate ad use the word "Translation" instead of "Translate"?

Could you please stop shuffling the deck and play already?

How many characters using PHB rules does it take to be able to have access to any PHB spell at the start of an adventuring day?

Does this video of collapsing warehouse shelves show a real incident?

Word for a person who has no opinion about whether god exists

NASA's RS-25 Engines shut down time

Intuition behind counterexample of Euler's sum of powers conjecture

How can I ensure my trip to the UK will not have to be cancelled because of Brexit?

Why the color red for the Republican Party

How is the wildcard * interpreted as a command?

Is "history" a male-biased word ("his+story")?

How to write ı (i without dot) character in pgf-pie

Why was Goose renamed from Chewie for the Captain Marvel film?



How to remove products linked to another store view?


Magento 2: Can you Filter By store_id Using a Product RepositoryMagento 2: Default REST API unable to update product data to multiple storesmagento 2 web rest api - Get all products with a specific attribute codeProducts not showing up when disabled on All Store Views and enabled on Specific Store ViewMagento 2 Admin- Invalid data provided for linked productsSimple products detached from configurabe products after importCorrect way to use an array of SKUs to filter collection results in M2Returning specific product search results before othersHow to set default store viewGetting the Product Name of one store view onto another













0















In MagentoCatalogImportExportModelExportProduct::collectRawData() :



There is the following lines starting at line 904:



$collection = $this->_getEntityCollection();
foreach ($this->_storeIdToCode as $storeId => $storeCode) {
$collection->setStoreId($storeId);


I would like to remove the products that are part of a specific store Code as it is causing duplicates during the export.



Is there perhaps a way to get the SQL query that puts the collection for a specific store view together?



Update:



I tried to find catalog_product_entity_* with store_id != 0 but there were none.



I have found that from MagentoCatalogImportExportModelExportProduct::collectRawData() the data returned is an associative array.



Consisting of a product for each storeview.
Funny thing is that where there are just 4 attributes per storeview, it is emptied out by this method $this->appendMultirowData($dataRow, $multirawData); but there is a case where more than 4 attributes come back for the storeview and that creates the duplicate on the excel spreadsheet.



Example of array with 4 elements



array(4)
sku:"DLN-22083"
store_id:1
product_id:3485
product_link_id:"3485"


Example of an array with 10 elements



array(10)
description:"<p>My Desc</p>"
technical_specifications:"<ul><li>Red</li></ul>"
_store:"shs_en"
_attribute_set:"Dies"
_type:"simple"
sku:"DLN-14426"
store_id:1
product_id:3484
product_link_id:"3484"


So if I can stop there extra attributes from being added then the product won't be added to the spreadsheet










share|improve this question
















bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Found that this has to do with html_entities not being decoded. THis has been fixed in the latest magento.

    – Stevie G
    Jul 18 '17 at 9:16











  • Fixed in github.com/magento/magento2/commit/… so should be fixed in 2.1.8

    – Stevie G
    Jul 18 '17 at 9:29
















0















In MagentoCatalogImportExportModelExportProduct::collectRawData() :



There is the following lines starting at line 904:



$collection = $this->_getEntityCollection();
foreach ($this->_storeIdToCode as $storeId => $storeCode) {
$collection->setStoreId($storeId);


I would like to remove the products that are part of a specific store Code as it is causing duplicates during the export.



Is there perhaps a way to get the SQL query that puts the collection for a specific store view together?



Update:



I tried to find catalog_product_entity_* with store_id != 0 but there were none.



I have found that from MagentoCatalogImportExportModelExportProduct::collectRawData() the data returned is an associative array.



Consisting of a product for each storeview.
Funny thing is that where there are just 4 attributes per storeview, it is emptied out by this method $this->appendMultirowData($dataRow, $multirawData); but there is a case where more than 4 attributes come back for the storeview and that creates the duplicate on the excel spreadsheet.



Example of array with 4 elements



array(4)
sku:"DLN-22083"
store_id:1
product_id:3485
product_link_id:"3485"


Example of an array with 10 elements



array(10)
description:"<p>My Desc</p>"
technical_specifications:"<ul><li>Red</li></ul>"
_store:"shs_en"
_attribute_set:"Dies"
_type:"simple"
sku:"DLN-14426"
store_id:1
product_id:3484
product_link_id:"3484"


So if I can stop there extra attributes from being added then the product won't be added to the spreadsheet










share|improve this question
















bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Found that this has to do with html_entities not being decoded. THis has been fixed in the latest magento.

    – Stevie G
    Jul 18 '17 at 9:16











  • Fixed in github.com/magento/magento2/commit/… so should be fixed in 2.1.8

    – Stevie G
    Jul 18 '17 at 9:29














0












0








0








In MagentoCatalogImportExportModelExportProduct::collectRawData() :



There is the following lines starting at line 904:



$collection = $this->_getEntityCollection();
foreach ($this->_storeIdToCode as $storeId => $storeCode) {
$collection->setStoreId($storeId);


I would like to remove the products that are part of a specific store Code as it is causing duplicates during the export.



Is there perhaps a way to get the SQL query that puts the collection for a specific store view together?



Update:



I tried to find catalog_product_entity_* with store_id != 0 but there were none.



I have found that from MagentoCatalogImportExportModelExportProduct::collectRawData() the data returned is an associative array.



Consisting of a product for each storeview.
Funny thing is that where there are just 4 attributes per storeview, it is emptied out by this method $this->appendMultirowData($dataRow, $multirawData); but there is a case where more than 4 attributes come back for the storeview and that creates the duplicate on the excel spreadsheet.



Example of array with 4 elements



array(4)
sku:"DLN-22083"
store_id:1
product_id:3485
product_link_id:"3485"


Example of an array with 10 elements



array(10)
description:"<p>My Desc</p>"
technical_specifications:"<ul><li>Red</li></ul>"
_store:"shs_en"
_attribute_set:"Dies"
_type:"simple"
sku:"DLN-14426"
store_id:1
product_id:3484
product_link_id:"3484"


So if I can stop there extra attributes from being added then the product won't be added to the spreadsheet










share|improve this question
















In MagentoCatalogImportExportModelExportProduct::collectRawData() :



There is the following lines starting at line 904:



$collection = $this->_getEntityCollection();
foreach ($this->_storeIdToCode as $storeId => $storeCode) {
$collection->setStoreId($storeId);


I would like to remove the products that are part of a specific store Code as it is causing duplicates during the export.



Is there perhaps a way to get the SQL query that puts the collection for a specific store view together?



Update:



I tried to find catalog_product_entity_* with store_id != 0 but there were none.



I have found that from MagentoCatalogImportExportModelExportProduct::collectRawData() the data returned is an associative array.



Consisting of a product for each storeview.
Funny thing is that where there are just 4 attributes per storeview, it is emptied out by this method $this->appendMultirowData($dataRow, $multirawData); but there is a case where more than 4 attributes come back for the storeview and that creates the duplicate on the excel spreadsheet.



Example of array with 4 elements



array(4)
sku:"DLN-22083"
store_id:1
product_id:3485
product_link_id:"3485"


Example of an array with 10 elements



array(10)
description:"<p>My Desc</p>"
technical_specifications:"<ul><li>Red</li></ul>"
_store:"shs_en"
_attribute_set:"Dies"
_type:"simple"
sku:"DLN-14426"
store_id:1
product_id:3484
product_link_id:"3484"


So if I can stop there extra attributes from being added then the product won't be added to the spreadsheet







magento2 magento-2.1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 18 '17 at 8:08







Stevie G

















asked Jul 17 '17 at 14:42









Stevie GStevie G

330625




330625





bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Found that this has to do with html_entities not being decoded. THis has been fixed in the latest magento.

    – Stevie G
    Jul 18 '17 at 9:16











  • Fixed in github.com/magento/magento2/commit/… so should be fixed in 2.1.8

    – Stevie G
    Jul 18 '17 at 9:29



















  • Found that this has to do with html_entities not being decoded. THis has been fixed in the latest magento.

    – Stevie G
    Jul 18 '17 at 9:16











  • Fixed in github.com/magento/magento2/commit/… so should be fixed in 2.1.8

    – Stevie G
    Jul 18 '17 at 9:29

















Found that this has to do with html_entities not being decoded. THis has been fixed in the latest magento.

– Stevie G
Jul 18 '17 at 9:16





Found that this has to do with html_entities not being decoded. THis has been fixed in the latest magento.

– Stevie G
Jul 18 '17 at 9:16













Fixed in github.com/magento/magento2/commit/… so should be fixed in 2.1.8

– Stevie G
Jul 18 '17 at 9:29





Fixed in github.com/magento/magento2/commit/… so should be fixed in 2.1.8

– Stevie G
Jul 18 '17 at 9:29










2 Answers
2






active

oldest

votes


















0














Actually products are not directly linked to any store view, but their values can be changed at store view level. So you can show different values for different store views.



For example, you have a product with the price $200 in default store view. You can change price for another store view to $100, if you want. The price information is saved in the table catalog_product_entity_decimal.



If you look at the table, you will see that there is a store_id field in it. This field makes it possible for you to define different values for each store view.



mysql> select * from catalog_product_entity_decimal;
+----------+--------------+----------+--------+----------+
| value_id | attribute_id | store_id | row_id | value |
+----------+--------------+----------+--------+----------+
| 1 | 77 | 0 | 1 | 111.0000 |
| 2 | 77 | 0 | 3 | 11.0000 |
| 3 | 77 | 0 | 4 | 200.0000 |
| 4 | 77 | 0 | 5 | 200.0000 |
| 5 | 77 | 0 | 6 | 200.0000 |
| 6 | 77 | 0 | 7 | 200.0000 |
| 7 | 77 | 0 | 8 | 200.0000 |
| 8 | 77 | 0 | 9 | 200.0000 |
| 9 | 77 | 1 | 9 | 100.0000 |
+----------+--------------+----------+--------+----------+



After all these explanation, let me show how to combine these values. First of all, you need to inject some dependencies in your constructor.



public function __construct(
MagentoFrameworkAppResourceConnection $resourceConnection,
)
{
$this->resourceConnection = $resourceConnection;
}


After that, you can run the following code block. This code block will combine a specific store view with the default one. The store view is stored in the variable $storeViewId.



// This is the specific store view id to be combined
$storeViewId = 1;
$resourceConnection = $this->resourceConnection;

// Get connection adapter
$connection = $resourceConnection->getConnection();

// Get tables names
$tableProductEntityDatetime = $resourceConnection->getTableName('catalog_product_entity_datetime');
$tableProductEntityDecimal = $resourceConnection->getTableName('catalog_product_entity_decimal');
$tableProductEntityInt = $resourceConnection->getTableName('catalog_product_entity_int');
$tableProductEntityText = $resourceConnection->getTableName('catalog_product_entity_text');
$tableProductEntityVarchar = $resourceConnection->getTableName('catalog_product_entity_varchar');

$tableNames = [
$tableProductEntityDatetime,
$tableProductEntityInt,
$tableProductEntityDecimal,
$tableProductEntityText,
$tableProductEntityVarchar
];
foreach ($tableNames as $tableName) {
$rowsAttributes = $connection->fetchAll("SELECT `value_id`, `attribute_id`, `value` FROM `{$tableName}` WHERE `row_id` = :row_id AND `store_id` = :store_view_id", [
'row_id' => $product->getRowId(),
'store_view_id' => $storeViewId
]);
foreach ($rowsAttributes as $row) {
$connection->delete($tableName, "`value_id` = {$row['value_id']}");
try {
$connection->insert($tableName, [
'attribute_id' => $row['attribute_id'],
'store_id' => 0,
'row_id' => $product->getRowId(),
'value' => $row['value']
]);
} catch (Exception $e) {
// Entry already created
}
}
}





share|improve this answer































    0














    After export open CSV in Excel and filter any specific store so you get unique value. If your purpose is only for remove duplicate in export file






    share|improve this answer

























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "479"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f184133%2fhow-to-remove-products-linked-to-another-store-view%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Actually products are not directly linked to any store view, but their values can be changed at store view level. So you can show different values for different store views.



      For example, you have a product with the price $200 in default store view. You can change price for another store view to $100, if you want. The price information is saved in the table catalog_product_entity_decimal.



      If you look at the table, you will see that there is a store_id field in it. This field makes it possible for you to define different values for each store view.



      mysql> select * from catalog_product_entity_decimal;
      +----------+--------------+----------+--------+----------+
      | value_id | attribute_id | store_id | row_id | value |
      +----------+--------------+----------+--------+----------+
      | 1 | 77 | 0 | 1 | 111.0000 |
      | 2 | 77 | 0 | 3 | 11.0000 |
      | 3 | 77 | 0 | 4 | 200.0000 |
      | 4 | 77 | 0 | 5 | 200.0000 |
      | 5 | 77 | 0 | 6 | 200.0000 |
      | 6 | 77 | 0 | 7 | 200.0000 |
      | 7 | 77 | 0 | 8 | 200.0000 |
      | 8 | 77 | 0 | 9 | 200.0000 |
      | 9 | 77 | 1 | 9 | 100.0000 |
      +----------+--------------+----------+--------+----------+



      After all these explanation, let me show how to combine these values. First of all, you need to inject some dependencies in your constructor.



      public function __construct(
      MagentoFrameworkAppResourceConnection $resourceConnection,
      )
      {
      $this->resourceConnection = $resourceConnection;
      }


      After that, you can run the following code block. This code block will combine a specific store view with the default one. The store view is stored in the variable $storeViewId.



      // This is the specific store view id to be combined
      $storeViewId = 1;
      $resourceConnection = $this->resourceConnection;

      // Get connection adapter
      $connection = $resourceConnection->getConnection();

      // Get tables names
      $tableProductEntityDatetime = $resourceConnection->getTableName('catalog_product_entity_datetime');
      $tableProductEntityDecimal = $resourceConnection->getTableName('catalog_product_entity_decimal');
      $tableProductEntityInt = $resourceConnection->getTableName('catalog_product_entity_int');
      $tableProductEntityText = $resourceConnection->getTableName('catalog_product_entity_text');
      $tableProductEntityVarchar = $resourceConnection->getTableName('catalog_product_entity_varchar');

      $tableNames = [
      $tableProductEntityDatetime,
      $tableProductEntityInt,
      $tableProductEntityDecimal,
      $tableProductEntityText,
      $tableProductEntityVarchar
      ];
      foreach ($tableNames as $tableName) {
      $rowsAttributes = $connection->fetchAll("SELECT `value_id`, `attribute_id`, `value` FROM `{$tableName}` WHERE `row_id` = :row_id AND `store_id` = :store_view_id", [
      'row_id' => $product->getRowId(),
      'store_view_id' => $storeViewId
      ]);
      foreach ($rowsAttributes as $row) {
      $connection->delete($tableName, "`value_id` = {$row['value_id']}");
      try {
      $connection->insert($tableName, [
      'attribute_id' => $row['attribute_id'],
      'store_id' => 0,
      'row_id' => $product->getRowId(),
      'value' => $row['value']
      ]);
      } catch (Exception $e) {
      // Entry already created
      }
      }
      }





      share|improve this answer




























        0














        Actually products are not directly linked to any store view, but their values can be changed at store view level. So you can show different values for different store views.



        For example, you have a product with the price $200 in default store view. You can change price for another store view to $100, if you want. The price information is saved in the table catalog_product_entity_decimal.



        If you look at the table, you will see that there is a store_id field in it. This field makes it possible for you to define different values for each store view.



        mysql> select * from catalog_product_entity_decimal;
        +----------+--------------+----------+--------+----------+
        | value_id | attribute_id | store_id | row_id | value |
        +----------+--------------+----------+--------+----------+
        | 1 | 77 | 0 | 1 | 111.0000 |
        | 2 | 77 | 0 | 3 | 11.0000 |
        | 3 | 77 | 0 | 4 | 200.0000 |
        | 4 | 77 | 0 | 5 | 200.0000 |
        | 5 | 77 | 0 | 6 | 200.0000 |
        | 6 | 77 | 0 | 7 | 200.0000 |
        | 7 | 77 | 0 | 8 | 200.0000 |
        | 8 | 77 | 0 | 9 | 200.0000 |
        | 9 | 77 | 1 | 9 | 100.0000 |
        +----------+--------------+----------+--------+----------+



        After all these explanation, let me show how to combine these values. First of all, you need to inject some dependencies in your constructor.



        public function __construct(
        MagentoFrameworkAppResourceConnection $resourceConnection,
        )
        {
        $this->resourceConnection = $resourceConnection;
        }


        After that, you can run the following code block. This code block will combine a specific store view with the default one. The store view is stored in the variable $storeViewId.



        // This is the specific store view id to be combined
        $storeViewId = 1;
        $resourceConnection = $this->resourceConnection;

        // Get connection adapter
        $connection = $resourceConnection->getConnection();

        // Get tables names
        $tableProductEntityDatetime = $resourceConnection->getTableName('catalog_product_entity_datetime');
        $tableProductEntityDecimal = $resourceConnection->getTableName('catalog_product_entity_decimal');
        $tableProductEntityInt = $resourceConnection->getTableName('catalog_product_entity_int');
        $tableProductEntityText = $resourceConnection->getTableName('catalog_product_entity_text');
        $tableProductEntityVarchar = $resourceConnection->getTableName('catalog_product_entity_varchar');

        $tableNames = [
        $tableProductEntityDatetime,
        $tableProductEntityInt,
        $tableProductEntityDecimal,
        $tableProductEntityText,
        $tableProductEntityVarchar
        ];
        foreach ($tableNames as $tableName) {
        $rowsAttributes = $connection->fetchAll("SELECT `value_id`, `attribute_id`, `value` FROM `{$tableName}` WHERE `row_id` = :row_id AND `store_id` = :store_view_id", [
        'row_id' => $product->getRowId(),
        'store_view_id' => $storeViewId
        ]);
        foreach ($rowsAttributes as $row) {
        $connection->delete($tableName, "`value_id` = {$row['value_id']}");
        try {
        $connection->insert($tableName, [
        'attribute_id' => $row['attribute_id'],
        'store_id' => 0,
        'row_id' => $product->getRowId(),
        'value' => $row['value']
        ]);
        } catch (Exception $e) {
        // Entry already created
        }
        }
        }





        share|improve this answer


























          0












          0








          0







          Actually products are not directly linked to any store view, but their values can be changed at store view level. So you can show different values for different store views.



          For example, you have a product with the price $200 in default store view. You can change price for another store view to $100, if you want. The price information is saved in the table catalog_product_entity_decimal.



          If you look at the table, you will see that there is a store_id field in it. This field makes it possible for you to define different values for each store view.



          mysql> select * from catalog_product_entity_decimal;
          +----------+--------------+----------+--------+----------+
          | value_id | attribute_id | store_id | row_id | value |
          +----------+--------------+----------+--------+----------+
          | 1 | 77 | 0 | 1 | 111.0000 |
          | 2 | 77 | 0 | 3 | 11.0000 |
          | 3 | 77 | 0 | 4 | 200.0000 |
          | 4 | 77 | 0 | 5 | 200.0000 |
          | 5 | 77 | 0 | 6 | 200.0000 |
          | 6 | 77 | 0 | 7 | 200.0000 |
          | 7 | 77 | 0 | 8 | 200.0000 |
          | 8 | 77 | 0 | 9 | 200.0000 |
          | 9 | 77 | 1 | 9 | 100.0000 |
          +----------+--------------+----------+--------+----------+



          After all these explanation, let me show how to combine these values. First of all, you need to inject some dependencies in your constructor.



          public function __construct(
          MagentoFrameworkAppResourceConnection $resourceConnection,
          )
          {
          $this->resourceConnection = $resourceConnection;
          }


          After that, you can run the following code block. This code block will combine a specific store view with the default one. The store view is stored in the variable $storeViewId.



          // This is the specific store view id to be combined
          $storeViewId = 1;
          $resourceConnection = $this->resourceConnection;

          // Get connection adapter
          $connection = $resourceConnection->getConnection();

          // Get tables names
          $tableProductEntityDatetime = $resourceConnection->getTableName('catalog_product_entity_datetime');
          $tableProductEntityDecimal = $resourceConnection->getTableName('catalog_product_entity_decimal');
          $tableProductEntityInt = $resourceConnection->getTableName('catalog_product_entity_int');
          $tableProductEntityText = $resourceConnection->getTableName('catalog_product_entity_text');
          $tableProductEntityVarchar = $resourceConnection->getTableName('catalog_product_entity_varchar');

          $tableNames = [
          $tableProductEntityDatetime,
          $tableProductEntityInt,
          $tableProductEntityDecimal,
          $tableProductEntityText,
          $tableProductEntityVarchar
          ];
          foreach ($tableNames as $tableName) {
          $rowsAttributes = $connection->fetchAll("SELECT `value_id`, `attribute_id`, `value` FROM `{$tableName}` WHERE `row_id` = :row_id AND `store_id` = :store_view_id", [
          'row_id' => $product->getRowId(),
          'store_view_id' => $storeViewId
          ]);
          foreach ($rowsAttributes as $row) {
          $connection->delete($tableName, "`value_id` = {$row['value_id']}");
          try {
          $connection->insert($tableName, [
          'attribute_id' => $row['attribute_id'],
          'store_id' => 0,
          'row_id' => $product->getRowId(),
          'value' => $row['value']
          ]);
          } catch (Exception $e) {
          // Entry already created
          }
          }
          }





          share|improve this answer













          Actually products are not directly linked to any store view, but their values can be changed at store view level. So you can show different values for different store views.



          For example, you have a product with the price $200 in default store view. You can change price for another store view to $100, if you want. The price information is saved in the table catalog_product_entity_decimal.



          If you look at the table, you will see that there is a store_id field in it. This field makes it possible for you to define different values for each store view.



          mysql> select * from catalog_product_entity_decimal;
          +----------+--------------+----------+--------+----------+
          | value_id | attribute_id | store_id | row_id | value |
          +----------+--------------+----------+--------+----------+
          | 1 | 77 | 0 | 1 | 111.0000 |
          | 2 | 77 | 0 | 3 | 11.0000 |
          | 3 | 77 | 0 | 4 | 200.0000 |
          | 4 | 77 | 0 | 5 | 200.0000 |
          | 5 | 77 | 0 | 6 | 200.0000 |
          | 6 | 77 | 0 | 7 | 200.0000 |
          | 7 | 77 | 0 | 8 | 200.0000 |
          | 8 | 77 | 0 | 9 | 200.0000 |
          | 9 | 77 | 1 | 9 | 100.0000 |
          +----------+--------------+----------+--------+----------+



          After all these explanation, let me show how to combine these values. First of all, you need to inject some dependencies in your constructor.



          public function __construct(
          MagentoFrameworkAppResourceConnection $resourceConnection,
          )
          {
          $this->resourceConnection = $resourceConnection;
          }


          After that, you can run the following code block. This code block will combine a specific store view with the default one. The store view is stored in the variable $storeViewId.



          // This is the specific store view id to be combined
          $storeViewId = 1;
          $resourceConnection = $this->resourceConnection;

          // Get connection adapter
          $connection = $resourceConnection->getConnection();

          // Get tables names
          $tableProductEntityDatetime = $resourceConnection->getTableName('catalog_product_entity_datetime');
          $tableProductEntityDecimal = $resourceConnection->getTableName('catalog_product_entity_decimal');
          $tableProductEntityInt = $resourceConnection->getTableName('catalog_product_entity_int');
          $tableProductEntityText = $resourceConnection->getTableName('catalog_product_entity_text');
          $tableProductEntityVarchar = $resourceConnection->getTableName('catalog_product_entity_varchar');

          $tableNames = [
          $tableProductEntityDatetime,
          $tableProductEntityInt,
          $tableProductEntityDecimal,
          $tableProductEntityText,
          $tableProductEntityVarchar
          ];
          foreach ($tableNames as $tableName) {
          $rowsAttributes = $connection->fetchAll("SELECT `value_id`, `attribute_id`, `value` FROM `{$tableName}` WHERE `row_id` = :row_id AND `store_id` = :store_view_id", [
          'row_id' => $product->getRowId(),
          'store_view_id' => $storeViewId
          ]);
          foreach ($rowsAttributes as $row) {
          $connection->delete($tableName, "`value_id` = {$row['value_id']}");
          try {
          $connection->insert($tableName, [
          'attribute_id' => $row['attribute_id'],
          'store_id' => 0,
          'row_id' => $product->getRowId(),
          'value' => $row['value']
          ]);
          } catch (Exception $e) {
          // Entry already created
          }
          }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 17 '17 at 20:09









          Bunyamin InanBunyamin Inan

          832625




          832625

























              0














              After export open CSV in Excel and filter any specific store so you get unique value. If your purpose is only for remove duplicate in export file






              share|improve this answer






























                0














                After export open CSV in Excel and filter any specific store so you get unique value. If your purpose is only for remove duplicate in export file






                share|improve this answer




























                  0












                  0








                  0







                  After export open CSV in Excel and filter any specific store so you get unique value. If your purpose is only for remove duplicate in export file






                  share|improve this answer















                  After export open CSV in Excel and filter any specific store so you get unique value. If your purpose is only for remove duplicate in export file







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 7 '17 at 4:05

























                  answered Jul 17 '17 at 16:37









                  Feedlay TechnologiesFeedlay Technologies

                  1459




                  1459






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f184133%2fhow-to-remove-products-linked-to-another-store-view%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

                      How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

                      夢乃愛華...