Reputation: 15934
I am loading a product like so:
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', 'MyStockCode');
Then I try to get the images using:
$existingGallery = $product->getMediaGallery('images');
but it comes back with a null value. When inspecting _data
against $product
the media_gallery
attribute is missing.
From all the references I have read, this is how to load the images against a product but this doesn't seem to be working for me.
Notes:
I can see the images in the admin area against that product so they are definitely there.
I am doing this in the admin area, not frontend.
Upvotes: 0
Views: 572
Reputation: 4076
try below code for getting product Image
$product->getImageUrl();
Upvotes: 0
Reputation: 5381
If you load by attribute give you collection so Recommendation is load product via its id So it will give you whole product object.
Fetch product id from $product object which you have already load and then load with product id.
$product = Mage::getModel('catalog/product')->load(product id);
then $product->getMediaGalleryImages()
give you all product images
Upvotes: 3