Page 1 of 2

[MOD] Related Video for Products - OC 1.4.8b

Posted: Mon Aug 02, 2010 6:47 pm
by SXGuy
Here are the instructions on how to create the mod.

This is for version 1.4.8b but should work for any previous version providing you follow the correct folder structure.
This was made created originally by me for 1.3.2 and updated to 1.4.8b

PLEASE PLEASE PLEASE BACK UP EVERYTHING YOU MODIFY BEFORE ADDING THIS MOD

I will not be responsible for anything you mess up while adding this modification.

Edit mysql database 'oc_product' table

insert new column after 'stock_status_id'

Name new column 'video'

i.e

Code: Select all

ALTER TABLE oc_product ADD video VARCHAR(60) AFTER stock_status_id;

/admin/controller/catalog/product.php

Find Line 493

Code: Select all

$this->data['entry_keyword'] = $this->language->get('entry_keyword');
Add underneath

Code: Select all

$this->data['entry_video'] = $this->language->get('entry_video');
Find Line 690

Code: Select all

$this->data['keyword'] = '';
}
Add after the closing bracket (Line 692)

Code: Select all

if (isset($this->request->post['video'])) {
         $this->data['video'] = $this->request->post['video'];
      } elseif (isset($product_info)) {
         $this->data['video'] = $product_info['video'];
      } else {
         $this->data['video'] = '';
      }
/admin/language/english/catalog/product.php

Find Line 32

Code: Select all

$_['entry_keyword']          = 'SEO Keyword:';
Add underneath

Code: Select all

$_['entry_video']            = 'Related Video:';
admin/model/catalog/product.php

Find Line 3

Code: Select all

public function addProduct($data) {
Locate

Code: Select all

stock_status_id = '" . (int)$data['stock_status_id'] . "',
Insert after the comma

Code: Select all

video = '" . $this->db->escape($data['video']) . "',

Find Line 98

Code: Select all

public function editProduct
Locate

Code: Select all

stock_status_id = '" . (int)$data['stock_status_id'] . "',
Insert after comma

Code: Select all

video = '" . $this->db->escape($data['video']) . "',

/admin/view/template/catalog/product_form.tpl

Find </tr> on line 159

insert after

Code: Select all

<tr>
     <td><?php echo $entry_video; ?></td>
     <td><input type="text" name="video" value="<?php echo $video; ?>" /></td>
</tr>
catalog/controller/product/product.php

find line 137

locate

Code: Select all

$this->data['text_qty'] = $this->language->get('text_qty');
insert after

Code: Select all

$this->data['text_video'] = $this->language->get('text_video');
find Line 238

Code: Select all

$this->data['model'] = $product_info['model'];
insert after

Code: Select all

$this->data['video'] = $product_info['video'];
catalog/model/catalog/product.php

Find Line 3

Code: Select all

public function getProduct($product_id) {
Locate

Code: Select all

ss.name AS stock FROM
replace with

Code: Select all

ss.name AS stock, video FROM
catalog/language/english/product/product.php

Find line 21

Insert after

Code: Select all

$_['text_video']        = 'Related Video';
catalog/view/theme/YOURTHEME/template/product/product.tpl

Find </table> on line 108

insert after

Code: Select all

<?php if ($video) { ?>
         <div align="center"><?php echo $text_video; ?><br>
        <object width="425" height="350"><param name="movie" value="<?php echo $video; ?>"></param><param name="wmode" value="transparent"></param><embed src="<?php echo $video; ?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>
</div>
    <?php } ?>

Now login to the admin side of opencart, go to Catalog Tab > Products > Data Tab
Go down to Related Video and paste a youtube link, or any other video link for example: http://www.youtube.com/v/PMJmqxl_eqM

You should now have related video for your product

Image

Q&A

Q: My video doesnt load why?

A: Some youtube links forbid embedding video, please check the link you are using.

Q: Ive checked the youtube link and it does allow embedding, but it still doesnt show, why?

A: Make sure you have followed every step, it is very easy to forget a section.

Q: Ive installed a new template but i have lost the related video.

A: You will need to replace the file located at catalog/view/theme/YOURTHEME/template/product/product.tpl
with the one included in this mod located at catalog/view/theme/default/template/product/product.tpl

I hope this helps all of you who have been messaging me over the last few months asking for the how to.
If anyone has problems, do not hesitate to contact me, but please make sure you follow all steps first, and check you have done everything correctly.


I have also attached the files needed should you be lazy :)

Re: [RELEASED] Related Video for Products - OC 1.4.8b

Posted: Mon Aug 02, 2010 11:41 pm
by musicofthehart
Works perfectly, Thanks!!!

Re: [RELEASED] Related Video for Products - OC 1.4.8b

Posted: Tue Aug 03, 2010 12:08 am
by OSWorX
Great enhancement and very good work!
But could be also easily achieved if instead the standard editor CKeditor the TinyMCE is used.

Re: [RELEASED] Related Video for Products - OC 1.4.8b

Posted: Tue Aug 03, 2010 3:34 pm
by SXGuy
Yes TinyMCE could be used instead, but correct me if im wrong, that would mean dropping a video into each and every product descripton right?

I would bet that its far more easier and quicker to use an input box under every data tab for each product.

You could go even further by just editing your mysql database and dropping links into the video collumn rather than having to sit on the admin panel doing it all waiting for each page to load, doing this method using the product description would take so much longer due to all the other code surrounding it.

I would love to see someone adapt this to be used with some kind of video download cart, you could easily replace the product image with the video to preview your download. that would be kinda cool.

EDIT: please let me know if you guys think it would be of benifit to have a custom width and height setting for each related video alongside the input box for the url link, if you feel this would be of benifit, i will add that to the how to for you all

Then you could have a default size to be dropped into the embedded code, or change the size should you wish.

Re: [RELEASED] Related Video for Products - OC 1.4.8b

Posted: Tue Aug 03, 2010 3:53 pm
by OSWorX
As said, this can be a great addition!
And well done and the displayed howto - kudos!

But it needs to adopting the core which can be avoided with the editor TinyMCE - and not everybody knows how to edit files.
And about that 'I would bet that its far more easier and quicker to use an input box under every data tab for each product': the editor is on per default and there is no extra tab needed.

Re: [RELEASED] Related Video for Products - OC 1.4.8b

Posted: Tue Aug 03, 2010 4:46 pm
by qahar
OSWorX wrote:And about that 'I would bet that its far more easier and quicker to use an input box under every data tab for each product': the editor is on per default and there is no extra tab needed.
i thinks its true..
but, however, it still cool stuff. I've been added to collection links

Re: [RELEASED] Related Video for Products - OC 1.4.8b

Posted: Tue Aug 03, 2010 6:24 pm
by SXGuy
Ok fair point guys :)

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Wed Aug 18, 2010 9:55 pm
by lpoolfan
Hi guys

New here, great mod by the way :) i seem to be having a problem, where do i find the oc_product file to edit it, ive searched my cPanel for hours and can't seem to find it :(, and i'm getting this error.

Error: Unknown column 'video' in 'field list'
Error No: 1054
SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, video FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.product_id = '52' AND pd.language_id = '1' AND p2s.store_id = '0' AND ss.language_id = '1' AND p.date_available <= NOW() AND p.status = '1'

Any help would be great :)

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Sat Aug 21, 2010 5:52 pm
by cmebd
ALTER TABLE oc_product ADD video VARCHAR(60) AFTER stock_status_id;
I think you will find that the reference to oc_ is the prefix to the tables within the dbase.

You need to either remove oc_ if you didn't set up a prefix for your tables OR change the query to "[yrprefix_]product"

HTH

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Sat Aug 21, 2010 7:25 pm
by SXGuy
cmebd wrote:
ALTER TABLE oc_product ADD video VARCHAR(60) AFTER stock_status_id;
I think you will find that the reference to oc_ is the prefix to the tables within the dbase.

You need to either remove oc_ if you didn't set up a prefix for your tables OR change the query to "[yrprefix_]product"

HTH
Correctamondo

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Wed Sep 01, 2010 9:44 pm
by silanli_53
SQL sorgusu:

ALTER TABLE product ADD video VARCHAR( 60 ) AFTER stock_status_id

MySQL çıktısı: Belgeler
#1060 - Duplicate column name 'video'

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Thu Sep 02, 2010 8:12 pm
by cavus34
PHP myadmin problem



SQL sorgusu:

ALTER TABLE oc_product ADD video VARCHAR( 60 ) AFTER stock_status_id

MySQL çıktısı: Belgeler
#1146 - Table 'derde.oc_product' doesn't exist

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Mon Sep 06, 2010 3:15 pm
by SXGuy
cavus34 wrote:PHP myadmin problem



SQL sorgusu:

ALTER TABLE oc_product ADD video VARCHAR( 60 ) AFTER stock_status_id

MySQL çıktısı: Belgeler
#1146 - Table 'derde.oc_product' doesn't exist
Its telling you the problem if you just read the error?

Either your table name isnt called oc_product or you did something wrong, my guess would be to look at "derde.oc_product"

Is THAT the name of your product table??? if not, then change the sql query to match the table name ::)

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Tue Sep 28, 2010 12:49 pm
by Gilmore
HI SXGuy,
I made a little edit in a few files.
  • catalog/view/theme/YOURTHEME/template/product/product.tpl
    catalog/controller/product/product.php
    catalog/language/english/product/product.php
I added the http://www.youtube.com/v/ link to template code. Now you only have to add the YouTube video ID number instead of the embed link in the products Admin data tab.
If the YouTube link is... http://www.youtube.com/watch?v=PMJmqxl_eqM
Then the YouTube ID code is PMJmqxl_eqM

In catalog/view/theme/YOURTHEME/template/product/product.tpl
Find:

Code: Select all

<?php if ($video) { ?>
         <div align="center"><?php echo $text_video; ?><br>
        <object width="425" height="350"><param name="movie" value="<?php echo $video; ?>"></param><param name="wmode" value="transparent"></param><embed src="<?php echo $video; ?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>
</div>
    <?php } ?>
Replace with:

Code: Select all

    <?php if ($video) { ?>
             <div align="center"><?php echo $text_video; ?><br>
            <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/<?php echo $video; ?><?php echo $youtube_products; ?>"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/<?php echo $video; ?><?php echo $youtube_products; ?>" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>
    </div>
        <?php } ?>
In catalog/language/english/product/product.php I added the YouTube extension, ?fs=1&hl=en_US&rel=0
FInd:

Code: Select all

$_['text_video']        = 'Related Video';
and after that add:

Code: Select all

$_['youtube_products']  = '?fs=1&hl=en_US&rel=0';
Now in catalog/controller/product/product.php
Find:

Code: Select all

    $this->data['text_video'] = $this->language->get('text_video');
And after that add:

Code: Select all

   $this->data['youtube_products'] = $this->language->get('youtube_products');
I hope everyone enjoys!

Gil

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Tue Sep 28, 2010 3:22 pm
by SXGuy
Cool addition.

I left it the full link originally because i wasnt sure if there were any other video hosting websites which work in a similar way, which then could be used instead of a youtube link.

But if people purely want it for youtube, then your modification makes it easier for them :)

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Mon Dec 13, 2010 9:58 pm
by aras
great work, I am too new to this so i'll wait a bit before trying this . this does not work with the latest version of opencart, right ??

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Mon Dec 13, 2010 11:27 pm
by SXGuy
as far as im aware it should work with any latest version of opencart, process should be the same, unless the model files have been changed, which i dont think they have.

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Fri Dec 24, 2010 2:25 am
by LadyRagefist
Thank you for this mod, it was more helpful than the actual support team. Go figure.

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Wed Jan 26, 2011 1:42 am
by pixel
Add player to this mod. Add projekktor player.
create a folder in default theme folder, named :: js :: (not :: this are only to see better)
download projekktor player from http://www.projekktor.com/
copy the projekktor.min.js, jarisplayer.swf files and the folder maccaco to the :: js :: folder
add this to the product.tpl
<script type="text/javascript" src="catalog/view/theme/default/js/projekktor.min.js"></script> <!-- load projekktor -->
<link rel="stylesheet" href="catalog/view/theme/default/js/minimum/style.css" type="text/css" media="screen" />
at the end of the page,

and this code

<video id="demoplayer" class="projekktor" title="plaster session" poster="image/data/logo.png" src="http://www.youtube.com/v/<?php echo $video; ?>" type="video/youtube" width="425" height="350" controls>
</video>

<script type="text/javascript">
$(document).ready(function() {
projekktor('#demoplayer', {plugin_logo: {logo:"image/data/logo.png"}});
})
</script>

Re: [MOD] Related Video for Products - OC 1.4.8b

Posted: Wed Jan 26, 2011 5:34 am
by SXGuy
nice addition cheers.