I am using the below code to display the main product image:
$productId = $this->getProduct_id();
$_product = Mage::getModel('catalog/product')->load($productId);
?>
<div class="single-image-large" onclick='window.open("<?php echo $_product->getProductUrl() ?>", "_self")'>
<img class="blog-image" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(400, 400) ?>" width="400" height="400" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /><span class="img-caption"><?php echo $this->htmlEscape($_product->getName()) ?></span>
</div>
I would like to edit it so that it shows the product's second image. Any ideas how to achieve this?
I feel you can fetch the other images by using
$_product->getMediaGalleryImages()->getItemByColumnValue('label', 'LABEL_NAME')->getUrl();
or fetch the whole gallery and display it as per your requirement
Mage::getModel(’catalog/product’)->load($productId)->getMediaGalleryImages();
Related
My website currently lets me upload 1 photo at a time for each of my listed vehicles. This process takes some time, and it would be convenient to be able to drop all photos into 1 field and have them upload properly. Any help is great!
<?php
if(isset($slider_image)){
if(!empty($slider_image)){
foreach($slider_image as $s){
?>
<div class="col-md-4 hide_me_<?php echo $s->id; ?>" style="margin-bottom:10px;">
<a href="<?php echo site_url('uploads/'.$s->image); ?>" class="lightbox">
<img src="<?php echo site_url('uploads/'.$s->image); ?>" alt="<?php echo $s->title; ?>" class="img-media ">
</a>
Remove Image
</div>
<?php
}
}
}
?>
Thanks,
I am trying to make changes to product page of Opencart where I am trying to show a video instead of the product image. If I hardcode the video id I am able to play the video instead of the product image. but, I plan to take the video id from database table oc_product and new column u_tube_url to be defined and linked. currently in the default theme the path of image is defined in the image column. but, I want to give youtube videoid instead of image path.
I think the changes has to be done in product page at
/catalog/view/theme/default/template/product/product.tpl
<?php if ($thumb || $images) { ?>
<ul class="thumbnails">
<?php if ($thumb) { ?>
<li>
<a class="thumbnail" href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>">
<img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" />
</a>
</li>
<?php } ?>
</ul>
<?php } ?>
I also think some changes might be required at /catalog/controller/product/product.php
I added a db column in product description table. then...
I made changes to include video instead of product image.
Step 1
Open file: catalog/view/theme/default/template/product/product.tpl
Find :
<li><a class="thumbnail" href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a></li>
Replace:
<li><a <embed src="http://www.youtube.com/embed/<?php echo $url_id; ?>?autoplay=0&rel=0" width="360" height="240"></embed></a><embed src="http://www.youtube.com/embed/<?php echo $url_id; ?>?autoplay=0&rel=0" width="360" height="240"></embed></li>
Step 2
Open file: admin/model/catalog/product.php
Add to :
url_id = '" . $this->db->escape($value['url_id']) . "',
Step 3
Open file: catalog/controller/product/product.php
Find :
$data['heading_title'] = $product_info['name'];
Add after :
$data['url_id'] = $product_info['url_id'];
Step 4
Open file: catalog/controller/product/product.php
Find :
'special' => $special,
Add after :
'url_id' => $result['url_id'],
Step 5
Open file: catalog/model/catalog/product.php
Find :
'description' => $query->row['description'],
Add after :
'url_id'=> $query->row['url_id'],
My apologies if this has been posted
I've created a PHP project and I'm using Wamp I've also got a database set up in phpmyadmin.
I am able to run my website and view my website, but when I click on a link (my catalog with different categories link to display products). The link redirects me to the wamp server page.
Does anyone have a solution to this, any help would be appreciated.
Code:
<a href="/?page=catalogue-item&category=<?php echo $category['id']; ?>&id=<?php echo $row['id']; ?>">
<img src="<?php echo $image; ?>" alt="<?php echo Helper::encodeHtml($row['name'], 1); ?>" width="<?php echo $width; ?>" />
</a>
Thanks in advance!
Try This:
<a href="?page=catalogue-item&category=<?php echo $category['id']; ?>&id=<?php echo $row['id']; ?>">
<img src="<?php echo $image; ?>" alt="<?php echo Helper::encodeHtml($row['name'], 1); ?>" width="<?php echo $width; ?>" />
</a>
/ Was was the actual problem which was making the link point to root instead of current page.
I need a small amount of help to start developing a script to get the color labels on list products in Magento. I do not want to switch the pictures on click, I simply want to show that there is more than 1 color available on that particular product.
Ok, i get the final script, but i cannot get the result of pictures below
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(155); ?>" width="155" height="155" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>
Script to get the associated images on list.
<?php $_images = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();?>
<?php if($_images){?>
<?php $i=0; foreach($_images as $_image){ $i++;?>
<a href="#">
<img src="<?=$this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(200, 130); ?>” width="200" height="130" alt="<?=$this->htmlEscape($_image->getLabel());?>" title="<?=$this->htmlEscape($_image->getLabel());?>" />
</a>
<?php }?>
<?php }?>
The script from the question is working perfect, just not the right place to explode it.
I'm using the following code in my view.phtml file to display a random featured product:
<?php
$catId = $this->getCat_id();
$cat=Mage::getModel("catalog/category")->load($catId);
$prodCollection = $cat->getProductCollection();
$pids=array();
foreach($prodCollection as $product)
{
array_push($pids,$product->getId());
}
$randProductId=array_rand($pids);
$product = Mage::getModel('catalog/product')->load($randProductId);
$product->getName();
?>
<div class="catalog-h-price">
<img src="<?php echo $product->getImageUrl();?>" height="64" width="64" /><?php echo $product->getName();?><br /><span class="price"><sup>$</sup><?php echo number_format($product->getData('price'), 0); ?></span> <span class="msrp">U.S. MSRP</span><a href="#"><a href="<?php echo $product->getProductUrl();?>">
<img src="http://coloresg.com/skin/frontend/default/modern/images/view-now.gif" width="36" height="28" /></a>
</div>
Currently it shows a random product from the entire catalog; I would like to know how adjust to pull only from current category.
Thanks,
-Sam
Answered the mistake in the other thread
Replace
$product = Mage::getModel('catalog/product')->load($randProductId);
by
$product = Mage::getModel('catalog/product')->load($pids[$randProductId]);