I have been trying to import products into Magento and images. The products are being imported and created properly but the images to not get imported.
I am aware of the basics of importing as I have done it in the past but cannot figure out what the issue is and what to do next.
some notes how and what I did:
I am aware to add a "/" before the image name
image name is case sensitive
upload images in media/import folder
media folder to be 777
Tried different folders like var/import or
media/catalog/product/import
Removed the .htcaccess file in media
Flushed cache
when i upload manually an image on a product it does show up properly
i tried specifying the _media_attribute_id in a column as 88 maybe
that should help but it didn't
If you have a Mage_Catalog_Model_Product, all you need to do is this:
$fn = '/absolute/path/to/image.jpg';
$types = array('thumbnail', 'small_image', 'image'); // or null if you already have the product's thumbnail, small image, and image set
$move = true; // move the source file, don't leave it sitting around
$exclude = false; // enabled in product view
$label = 'Turquoise';
$product->addImageToMediaGallery($fn, $types, $move, $exclude); // Strictly speaking, only the first parameter is required
if(!empty($label)) {
$gallery = $product->getData('media_gallery');
$gallery_img = array_pop($gallery);
$gallery_img['label'] = $label;
array_push($gallery['images'], $gallery_img);
$product->setData('media_gallery', $gallery);
}
$product->save();
I have faced the same problem while uploading product image. And i tested many methods to figure that out. But nothing helped me. At last in one of the tutorial I have seen that the image name and the sku name has to be same. with the extension of file extension. So i followed it and by God's grace it worked. You may try that also. It worked for me. I had spent almost one full day to figure that out.
Related
I'm trying to import images in the magento importer but nothings appearing. I've gone through all the threads and I'm sure I've done everything I'm supposed to do and now I'm at a complete loss for what the problem could be.
I've created a folder called "import" in my "media" folder and placed the image 'blog-1.jpg' in it and my data is saved in a .csv and it looks similar to this: (i've copied the entries manually for readability)
sku - test1
name - test1
description - Test
short_description - Test
status - 1
visibility - 4
tax_class - 2
qty - 1
price - 1
weight - 1
image - /blog-1.jpg
image_label - Hello
small_image - /blog-1.jpg
small_image_label - Hello
thumbnail - /blog-1.jpg
thumbnail_label - Hello
When I "check" my data it says the data is fine and its found a field. Everything else gets imported correctly but when I click on "images" it has no images in there.
First of all your image are store in media>import folder.
Then in your csv file just write in image column /imagename.jpg
It will find same imagename in import folder if image exist then it will upload the image.
I'm sorry to say, but there is more going on behind the scenes with magento images that it simply putting a filename in the database and linking to your image. The cache generation alone is pretty complex. I believe you are going to have a hard time doing it the way you are attempting.
That being said, I do have a suggestion. Since your images are already on the server, I suggest you write a simple php script to tell magento to attach them to the product image. This could be automated, but i'll give you a small example below...
To attach an image, you would simply navigate to the url like this http://yoursite.com/imageattacher.php?sku=YOURSKU&image=yourimagefilename.jpg
The script would be like this... create a file in your magento ROOT and call it imageattacher.php. Upload your images to the magento media import directory. I have not tested this but it should work.
<?php
// Initialize magento for use outside of core
umask(0);
require_once 'app/Mage.php';
Mage::app('admin');
// Get the variables from the URL
$sku = $_GET["sku"];
$imageName = $_GET["image"];
// get the image from the import dir
$import = Mage::getBaseDir('media') . DS . 'import/' . $imageName;
// Load the product by sku
$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
// if the product exists, attempt to add the image to it for all three items
if ($product->getId() > 0)
{
// Add the images and set them for their respective usage (the radio button in admin)
$product->addImageToMediaGallery($import,array('image', 'small_image', 'thumbnail'),false,false);
// Make the changes stick
$product->save();
}
?>
I have taken over a site and am looking for some assistance.
The site currently detects if a product has a scene7 image set associated to it, and then adds IS to the code to display the image set.
I am trying to do this for category image as well, if I hardcode _IS (product sku + _ID) the image set is loaded nicely, but obviously any product sku with no image set, the image doesn't load.
This is the code with the _IS hardcoded:
flyoutViewer.setAsset("/${catalogEntryDetails.partNumber}_IS");
This snippet of code detects whether there is a set or not:
var asset = '/' + wc.render.getContextById('ItemDetailsContext').properties.partNumber;
if (data['catalogRecord.exists'] == 1) {
asset += 'IS';
}
Am I missing something major? My guess I am, I can dig out more code if necessary.
Help would be appreciated?!
I my thumbnails are not showing properly for multiple image view. On the admin side I can see all the different image set for a single product. I selected the default main, base and thumbnail image but on the front end I only see the default image. The other images dont show instead the default image is repeated.
Ok nevermind I have found the problem. An extension was causing the conflict. I just simply unistalled the extension and everything started working Ok.
The culprit extension is called, 'Image Permalink' or 'IG_NamedImages' in the magento connect.
Please let me know if anyone was having the same problem
I fixed this module editing the IG_NamedImages_Model_Product_Image as the following:
class IG_NamedImages_Model_Product_Image extends Mage_Catalog_Model_Product_Image
{
public function setBaseFile($file)
{
parent::setBaseFile($file);
if (Mage::helper('ig_namedimages')->getIsEnabled()){
$product = $this->getProduct();
$imageName = Mage::getSingleton('catalog/product_url')->formatUrlKey($product->getName());
$this->_newFile = preg_replace('/\/([^\/]+\.\w+)$/', '/'.$imageName.'-\1', $this->_newFile);
}
return $this;
}
}
I'm using a Magento 1.4.1.1 install that I'm having issues with the javascript on a custom themed store.
For example, going to any product page (e.g. http://www.papakuraeducation.co.nz/index.php/teachers/magic-caterpillar-handwriting-casey-caterpillar-small-book.html) loads a Javascript file, which contains code which is supposed to scale down the .jpg file to fit the 'product-image' container it sits inside.
The relevent code seems to be around line #10279, which is causing a exception that $(imageEl).parentNode = null
Product.Zoom.prototype = {
initialize: function(imageEl, trackEl, handleEl, zoomInEl, zoomOutEl, hintEl){
this.containerEl = $(imageEl).parentNode;
this.imageEl = $(imageEl);
this.handleEl = $(handleEl);
this.trackEl = $(trackEl);
this.hintEl = $(hintEl);
(snipped...)
I've tried debugging it in Chrome and adding breakpoints, but tbh I'm not actually sure how to use this information to find the solution.
Any help in pointing me in the right direction would be greatly appreciated.
You have to add an ID to the <IMG> in question. This ID should than be fed into the following code-space:
product_zoom = new Product.Zoom('IMAGE_ID', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
I'm using an add Print order button to print a customer's order (not invoice) and I can't figure out how to get the logo to show up on the pdf. The following is the code that is in the extension but I can't find the function to manipulate it and I don't understand why it's not pulling the logo that I have in configuration. Please advise. :)
$this->insertLogo($page, $order->getStore());
You probably don't have store logo for PDF set. In admin you should go to
System -> Configuration -> Sales -> Sales -> Invoice and Packing Slip Design
and set your logo there.
Now for the logn explanation in case the above won't work :)
insertLogo function is located in class Mage_Sales_Model_Order_Pdf_Abstract (I asume that your class derives from it).
The rows that you should note are $image = Mage::getStoreConfig('sales/identity/logo', $store); and $image = Mage::getBaseDir('media') . '/sales/store/logo/' . $image;
getStoreConfig function is looking for the name of logo image in core_config_data table. You can check if the value is set with
SELECT * FROM core_config_data WHERE path = 'sales/identity/logo'
If the query won't return anything or will return value that is not an image name then you'll have to set that value first.
If that value is set you should have a look in
/your_store_root_dir/media/sales/store/logo/value_that_is_in_the_database
to see if the store logo image realy exists and if it doesn't add it there.
Did you check code in that class ($this) and/or its parent class? You'll see function inserLogo there.