3

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

VP.
  • 15,509
  • 17
  • 91
  • 161
Ranjit
  • 125
  • 10
  • 1
    First you will have to add new database field, and also, i think that you will have to change product query in model, too.... And, then, consequently, admin panel (related views, models, controllers)... So, maybe it would be easier to find some extension which will do the job: http://www.opencart.com/index.php?route=extension/extension&filter_search=youtube%20product%20video – sinisake Aug 10 '15 at 15:58
  • Thanks nevermind...but my requirement was to replace the product image with the video...the extensions available are in the discription which anayways we can put in CKEditor. any other suggestion? – Ranjit Aug 10 '15 at 17:09
  • 1
    Ah, so... well... if there is no extension, you will have to do 'dirty job' by your self... If images/thumbs always (if there is no option: images OR yt links/videos) will be replaced with youtube link - it is little easier. Start with clean open cart installation - check database first -> see if you can add field without messing anything up... Then check related views, models, controllers... Opencart code is pretty clean and readable... Task is not too hard, but it is not trivial, too, and takes some time... :) – sinisake Aug 10 '15 at 17:48
  • @nevermind i tried doing the above step...i think i am nearing the solution...now i get the below error: Notice: Undefined index: url_id in /home/nextgen1/public_html/vqmod/vqcache/vq2-catalog_controller_product_product.php on line 294Notice: Undefined index: url_id in /home/nextgen1/public_html/vqmod/vqcache/vq2-catalog_controller_product_product.php on line 502 at line 294 I have $data['url_id'] = $product_info['url_id']; at line 502 i have $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'url_id' => $result['url_id'], – Ranjit Aug 10 '15 at 18:53
  • I was able to figure out the issues and resolve it myself thanks to @nevermind to guide me. – Ranjit Aug 11 '15 at 05:19

1 Answers1

3

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'],
HDP
  • 4,005
  • 2
  • 36
  • 58
Ranjit
  • 125
  • 10
  • please edit your answer & add your answer with code step by step. which code have you used there? or what changes there? So, it can be helpful another person. Thanks. – HDP Aug 11 '15 at 05:44