Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use all images from my default store on my new store view

I have a new store view and i've updated all the products using the magento admin: **Manage Products > Select all > Update Attributes** and then selecting the new store. Now that all my products are affiliated with my new store view i'm having a problem with all my images. On the front end it shows all placeholders. In the admin panel when i click on a product and then images.. it may have images but it's not selected to use base image, small image or thumbnail.

Is there a way to update all images on my new store view to use the default store view main images?

require_once 'abstract.php';

class Attach_Default_Store_Images Extends Mage_Shell_Abstract {

    public function run()
    {
        $products = Mage::getModel('catalog/product')->getCollection();
        foreach ($products as $product) {
            $productFrom = $product->setStoreId(1)->getImage();
            $productTo = $product->setStoreId(13)
            ->setImage($productFrom)
            ->setSmallImage($productFrom)
            ->setThumbnail($productFrom);
            echo "Images Updated\n";
            $product->save();
   }

        Mage::getModel('catalog/product_image')->clearCache();
        echo "Image Cache Cleared\n";

    }


    public function usageHelp()
    {
        return <<<USAGE
Usage:  php -f cache.php -- [options]
        php -f cache.php -- clean

  clean             Clean Old Cache
  help              This help

USAGE;
    }
}

$shell = new Attach_Default_Store_Images();
$shell->run();

Run a shell script with above?

like image 763
thismethod Avatar asked Aug 29 '16 18:08

thismethod


People also ask

How to change default store view Magento 2?

1. Go to Stores > All Stores and choose the Store you want to change the default store view for. 2. In the Default Store View section set the Store View you want to be a default one for this particular store and press Save Store button.

How do I change the store code in Magento 2?

Navigate to Stores > Configuration > General > Web and find the Url Options section. There you choose to Add Store Code to URLs selecting Yes from the corresponding select box and Save Config.


1 Answers

You can use magmi for this , just export the products CSV from magento admin, and re-import the required fields like SKU, image, small_image and thumbnail through magmi and it will do your work very fast and easily.

like image 171
Rohit Goel Avatar answered Oct 02 '22 11:10

Rohit Goel