- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2015
06:29 PM
07-01-2015
06:29 PM
Generate Thumbnail Programmatically
<?php ini_set('display_errors',1); error_reporting(E_ALL); ini_set('max_execution_time', -1); ini_set('memory_limit', -1); require_once('app/Mage.php'); Mage::app(); $collection = Mage::getModel('catalog/product')->getCollection(); $count_images = 0; $urls = ""; foreach($collection as $product) { $_product = Mage::getModel('catalog/product')->load($product->getId()); $_gallery = $_product->getMediaGalleryImages(); $count_images += count($_gallery); foreach($_gallery as $image) { $image_path = realpath('media/catalog/product/'.$image->getFile()); echo $image_path.' ->'.Mage::helper('catalog/image')->init($_product->getProduct(), 'thumbnail', $image_path)->keepAspectRatio(TRUE)->resize(200,null)."\n"; } } echo "$count_images thumbnail generated"; ?>
This is my code to generate product thumbnail for the specific size manually via terminal
php generate_thumbnail_all.php
But it only work on some machine.
But the code have no errors.
The script not work but if i browse magento catalog page, the thumbnail generated.
Labels:
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2015
11:55 PM
07-02-2015
11:55 PM
Re: Generate Thumbnail Programmatically [solved]
[solved]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2016
04:47 AM
02-05-2016
04:47 AM
Re: Generate Thumbnail Programmatically [solved]
Care to post the resolution?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2016
06:56 AM
04-10-2016
06:56 AM
Re: Generate Thumbnail Programmatically [solved]
require_once('app/Mage.php');
The above line fails to resolve in Magento v2.04