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 codeHow to remove default store view code from URL in Magento 2.1?Products 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 importMagento 2 store view for mobile and another for desktopCorrect way to use an array of SKUs to filter collection results in M2How to set default store view

What is the metal bit in the front of this propeller spinner?

Are there foods that astronauts are explicitly never allowed to eat?

Adding gears to my grandson's 12" bike

I have a domain, static IP and many devices I'd like to access outside my house. How to route them?

What does a Nintendo Game Boy do when turned on without a game cartridge inserted?

Did Don Young threaten John Boehner with a 10 inch blade to the throat?

What is the standard representation of a stop which could be either ejective or aspirated?

How did pilots avoid thunderstorms and related weather before “reliable” airborne weather radar was introduced on airliners?

Why are Oscar, India, and X-Ray (O, I, and X) not used as taxiway identifiers?

Do I care if the housing market has gone up or down, if I'm moving from one house to another?

Quickest way to move a line in a text file before another line in a text file?

Count the identical pairs in two lists

Function pointer parameter without asterisk

Storyboarding Approaches for the Non-Artistic

Is it OK to accept a job opportunity while planning on not taking it?

Why was Quirrell said to be in the Black Forest if Voldemort was actually in Albania?

How to handle not being able to attend as often as I'd like

What kind of vegetable has pink and white concentric rings?

Is it better to have a 10 year gap or a bad reference?

Finding Greatest Common Divisor using LuaLatex

Why is DC so, so, so Democratic?

Can a creature sustain itself by eating its own severed body parts?

Is there an English word to describe when a sound "protrudes"?

Does switching on an old games console without a cartridge damage it?



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 codeHow to remove default store view code from URL in Magento 2.1?Products 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 importMagento 2 store view for mobile and another for desktopCorrect way to use an array of SKUs to filter collection results in M2How to set default store view






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















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
























  • 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

















2















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
























  • 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













2












2








2








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

3507 silver badges26 bronze badges




3507 silver badges26 bronze badges












  • 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

          9869 silver badges27 bronze badges




          9869 silver badges27 bronze badges























              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 bronze badges




                  1459 bronze badges



























                      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

                      Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                      Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form