Currently in My Site I have 2 Store

  1. Store 1
  2. Store 2

I Want copy Data "Store 2" to "Store 1"

Any help would be greatly appreciated.

  • You can enable 2nd store also in the product rather than transferring all to that store again. – Prasad D. Warnakulasuriya Feb 14 at 11:24
  • not understanding please explain briefly – Rk Rathod Feb 14 at 11:35

In vendor/magento/module-catalog/Controller/Adminhtml/Product/Save.php File You Can See copyToStores Function.

After Review This Function I Got The Solution.


use Magento\Framework\App\Bootstrap;

require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$obj = $bootstrap->getObjectManager();
$state = $obj->get('Magento\Framework\App\State');

$productFactory = $obj->get('\Magento\Catalog\Model\ProductFactory');

$productCollection = $productFactory->create()->getCollection()
try {
    foreach ($productCollection as $productId) {
        echo "Product Id :- " . $productId, PHP_EOL;
} catch (\Exception $e) {
    echo "Error :- " . $e->getMessage(), PHP_EOL;

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.