Jump to content
Sign in to follow this  
Terra

Product Documents

Recommended Posts

NEW CONTRIBUTION!

 

Download:

http://www.oscommerce.com/community/contributions,4560

 

Description

Product Documents allows you to upload files in your admin area and link them to one or more products. The files are then accessible on product_info.php for viewing/downloading. Suitable for linking PDF, PowerPoint, Word, Text files to products as part of product description.

 

Limitations:

This contrib has no multi-language support

Not tested with MySQL 5.x

Not tested with register globals off

 

Please use this support thread for queries, help & bugs!

Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites

Hello, im having a bit of trouble.

 

The install went nicely, but everytime I access the document.php from admin I get.

 

ERROR:Documents folder does not exist.

 

 

I have it in the catalog/ directory, I have checked the defines and all are correct but no matter what I do I cannot get it to find the documents folder.

 

Any help would be appreciated. Thanks

Share this post


Link to post
Share on other sites
ERROR:Documents folder does not exist.

Can you double-check both your configure.php files & make sure that the pathway definition is in there & correct? Please also post both pathway definitions (admin / catalog) on this thread (not the whole file - just the relevant pathway definition). I'd focus on these two files ... it's the most likely cause. Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites

how many files can you upload per product? Is it possible to upload mor than 1 and have each document listed for download?

 

any screenshots of what this contrib looks like both on client and admin side?

Share this post


Link to post
Share on other sites

in catalog/includes/configure.php

 

define('DIR_WS_DOCUMENTS', 'documents/');

 

 

in catalog/admin/includes/configure.php

 

define('DIR_FS_CATALOG_DOCUMENTS', DIR_FS_CATALOG . 'documents/');

 

 

 

I placed he documents directory in catalog/ (catalog/documents/)

Edited by Sputnik77

Share this post


Link to post
Share on other sites
how many files can you upload per product? Is it possible to upload mor than 1 and have each document listed for download? any screenshots of what this contrib looks like both on client and admin side?

No screenshots - didn't have time but if anybody can post some, would be great. And yes - you can list more than 1 document ... it works similarly to "product attributes" ... you upload one document, then link it to as many products you want. No limits but please read my notes in the install file regarding bandwidth / disk space ... if you go overboard, you might need a dedicated server :lol: Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
in catalog/includes/configure.php

define('DIR_WS_DOCUMENTS', 'documents/');

in catalog/admin/includes/configure.php

define('DIR_FS_CATALOG_DOCUMENTS', DIR_FS_CATALOG . 'documents/');

I hope you are on an Apache server? Or do we have a Windows user here?

And what happens when you simply remove the validation (lines 114-119 in /admin/documents.php)?

NB: this is roughly the same code as used in /admin/categories.php line 325-330 .. if it works there it *should* work in documents.php. Similary the define path in /admin/includes/configure.php for DIR_FS_CATALOG_DOCUMENTS should be similar to the path for DIR_FS_CATALOG_IMAGES.

Terra

Edited by Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites

Is there a way to redirect documents downloads to avoid direct link or direct download? Like normal osc download feature when enabling "redirect Download".

 

Thank you for the contrib, run like a chamb.

 

Normando

Edited by PicsOne

Share this post


Link to post
Share on other sites
Is there a way to redirect documents downloads to avoid direct link or direct download? Like normal osc download feature when enabling "redirect Download".

I did consider this but thought it was overkill for what I needed - you should however be able to code this yourself by re-using the osCom code as used in download.php - you'll probably need a new page with the relevant code. Terra

PS: can I ask why you want a redirect?


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites

Hallo Edith,

 

Could you elaborate on your statement "(not suitable for shops with more than one language)".

 

Does it mean I could not translate the language files for the interface, or does it mean it could not sort documents according to language?

 

If more than one document can be linked to a product then I could do so with handbuch_deutsch, manual_english, manual_vietnamese etc. and the user just downloads his language version.

 

Michael

Share this post


Link to post
Share on other sites
Could you elaborate on your statement "(not suitable for shops with more than one language)".

 

Files are uploaded per product, but cannot be specified per language. That means that the same documents will be visible in all languages. So to answer your query you cannot sort by language. But you can of course upload the different language versions & the user just selects the right manual. Hope this answers it! Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites

Hello I also have the same problem with Apache:

Documents is indeed uploadé in catalog / documents / but in the downloading he(it) is not found.

Even with the road absolute in configure.php

the link is :DIR_WS_DOCUMENTSblabla.pdf

I put in configure.php : define('DIR_WS_DOCUMENTS', '/documents/');

But nothing ...

Share this post


Link to post
Share on other sites

Now:

1146 - Table 'db174120361.TABLE_DOCUMENTS' doesn't exist

 

SELECT d.documents_description, d.documents_file_name from TABLE_DOCUMENTS d, TABLE_DOCUMENTS_PRODUCTS dc, products p WHERE dc.products_id = '51' and dc.products_id = p.products_id and dc.documents_id = d.documents_id and p.products_status = '1'

 

[TEP STOP]

 

 

 

But they exists ... mysql 5

I understand nothing ...

Edited by NEMROD34

Share this post


Link to post
Share on other sites
Now:

1146 - Table 'db174120361.TABLE_DOCUMENTS' doesn't exist

 

SELECT d.documents_description, d.documents_file_name from TABLE_DOCUMENTS d, TABLE_DOCUMENTS_PRODUCTS dc, products p WHERE dc.products_id = '51' and dc.products_id = p.products_id and dc.documents_id = d.documents_id and p.products_status = '1'

 

[TEP STOP]

But they exists ... mysql 5

I understand nothing ...

Check that you did not forget this install step:

** In /includes/database_tables.php ** ADD **

define('TABLE_DOCUMENTS', 'documents');

define('TABLE_DOCUMENTS_PRODUCTS', 'documents_products');

And just to warn you - the contrib was written & tested in MySQL4 so you may need to modify it.

 

all the best - Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites

Great contribution, installed with no problems! How would I go about having the documents file name appear in the drop down box in #2 Product Documents, rather than the Document Name? I want the document name to be "sizing" in all instances so that "sizing" is what appears on the product pages. However if I enter sizing for DocumentName, then I have no way of knowing which sizing file to use unless I am able to see the actual file name. Thanks!

Share this post


Link to post
Share on other sites

Around Line 363 FIND:

 

<?php

$files = tep_db_query("select documents_id, documents_description from " . TABLE_DOCUMENTS . "");

while($file_details = tep_db_fetch_array($files)) {

if ($document_details['documents_id'] == $file_details['documents_id']) {

echo "\n" . '<option name="' . $file_details['documents_description'] . '" value="' . $file_details['documents_id'] . '" SELECTED>' . $file_details['documents_description'] . '</option>';

} else {

echo "\n" . '<option name="' . $file_details['documents_description'] . '" value="' . $file_details['documents_id'] . '">' . $file_details['documents_description'] . '</option>';

}

}

?>

 

CHANGE TO:

 

<?php

$files = tep_db_query("select documents_id, documents_file_name, documents_description from " . TABLE_DOCUMENTS . "");

 

while($file_details = tep_db_fetch_array($files)) {

if ($document_details['documents_id'] == $file_details['documents_id']) {

echo "\n" . '<option name="' . $file_details['documents_file_name'] . ' - [ ' . $file_details['documents_description'] . ' ]" value="' . $file_details['documents_id'] . '" SELECTED>' . $file_details['documents_file_name'] . ' - [ ' . $file_details['documents_description'] . ' ]</option>';

} else {

echo "\n" . '<option name="' . $file_details['documents_file_name'] . ' - [ ' . $file_details['documents_description'] . ' ]" value="' . $file_details['documents_file_name'] . ' - [ ' . $file_details['documents_description'] . ' ]">' . $file_details['documents_description'] . '</option>';

}

}

?>

 

Also around Line 414 FIND:

 

<?php

$files = tep_db_query("select * from " . TABLE_DOCUMENTS . " order by documents_file_name");

while ($file_details = tep_db_fetch_array($files)) {

echo '<option name="' . $file_details['documents_description'] . '" value="' . $file_details['documents_id'] . '">' . $file_details['documents_description'] . '</option>';

}

?>

 

CHANGE TO:

 

<?php

$files = tep_db_query("select * from " . TABLE_DOCUMENTS . " order by documents_file_name");

 

while ($file_details = tep_db_fetch_array($files)) {

echo '<option name="' . $file_details['documents_file_name'] . ' - [ ' . $file_details['documents_description'] . ' ]" value="' . $file_details['documents_id'] . '">' . $file_details['documents_file_name'] . ' - [ ' . $file_details['documents_description'] . ' ]</option>';

}

?>

 

 

This will show you the documents actual download file and after the description you have given it in admin.

Edited by insomniac2

Share this post


Link to post
Share on other sites

There is also an incorrect query which does not pull the proper product that you are working on when you do an edit.

This will fix the problem by selecting the current product you are working on for you.

 

Find Around line 339:

 

$documents = "select d.documents_description, d.documents_id, dc.documents_products_id, pd.products_name from " . TABLE_DOCUMENTS_PRODUCTS . " dc left join " . TABLE_DOCUMENTS . " d on dc.documents_id = d.documents_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on dc.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by dc.documents_products_id";

 

REPLACE WITH:

 

$documents = "select d.documents_description, d.documents_id, dc.products_id, dc.documents_products_id, pd.products_id, pd.products_name from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id left join " . TABLE_DOCUMENTS_PRODUCTS . " dc on dc.products_id = pd.products_id LEFT JOIN " . TABLE_DOCUMENTS . " d ON dc.documents_id = dc.documents_id where dc.products_id = pd.products_id and pd.products_id = p.products_id and dc.products_id = pd.products_id and pd.language_id = '" . $languages_id . "'";

Edited by insomniac2

Share this post


Link to post
Share on other sites

Sorry IGNORE THAT LAST POST.

 

It seems that this whole file is not correctly using languages. When I added a new document it added the file to all the products in all languages .. so now I have listed 3 documents for each product. One document for each language.

 

I will try to look into it. I think when inputing a new file code needs to be added to specify which language the document is in.

 

This will also require adding the language_id field to the TABLE_DOCUMENTS_PRODUCTS and TABLE_DOCUMENTS .. which could lead to some work .. LOL

Share this post


Link to post
Share on other sites

OK got it fixed now to show proper product you are editing.

 

FIND approximate lines 337 to 360 which read:

 

<?php

 

$documents = "select d.documents_description, d.documents_id, dc.documents_products_id, pd.products_name FROM " . TABLE_DOCUMENTS_PRODUCTS . " dc LEFT JOIN " . TABLE_DOCUMENTS . " d ON dc.documents_id = d.documents_id LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON dc.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by dc.documents_products_id";

$next_id = 1;

$documents = tep_db_query($documents);

 

while ($document_details = tep_db_fetch_array($documents)) {

?>

<tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

<?php

if (($action == 'update_document') && ($HTTP_GET_VARS['documents_products_id'] == $document_details['documents_products_id'])) {

?>

<td class="smallText"> <?php echo $document_details['documents_products_id']; ?><input type="hidden" name="documents_products_id" value="<?php echo $document_details['documents_products_id']; ?>"> </td>

<td class="smallText"> <select name="products_id">

<?php

$products = tep_db_query("select p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "' order by pd.products_name");

while($products_values = tep_db_fetch_array($products)) {

if ($document_details['products_id'] == $products_values['products_id']) {

echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $products_values['products_name'] . '</option>';

} else {

echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . '</option>';

}

}

?>

 

AND REPLACE the WHOLE SECTION with:

 

<?php

 

$documents = "select d.documents_description, d.documents_id, dc.documents_products_id, pd.products_name from " . TABLE_DOCUMENTS_PRODUCTS . " dc left join " . TABLE_DOCUMENTS . " d on dc.documents_id = d.documents_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on dc.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by dc.documents_products_id";

 

$next_id = 1;

$documents = tep_db_query($documents);

 

while ($document_details = tep_db_fetch_array($documents)) {

?>

<tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">

<?php

if (($action == 'update_document') && ($_GET['documents_products_id'] == $document_details['documents_products_id'])) {

?>

<td class="smallText" align="right"> <?php echo $document_details['documents_products_id']; ?><input type="hidden" name="documents_products_id" value="<?php echo $document_details['documents_products_id']; ?>"></td>

<td class="smallText">   <select name="products_id">

<?php

$products = tep_db_query("select d.documents_description, d.documents_id, dc.documents_products_id, pd.products_name from " . TABLE_DOCUMENTS_PRODUCTS . " dc left join " . TABLE_DOCUMENTS . " d on dc.documents_id = d.documents_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on dc.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by dc.documents_products_id");

 

while($products_values = tep_db_fetch_array($products)) {

 

if ($_GET['documents_products_id'] == $products_values['documents_products_id']) {

echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '" SELECTED>' . $products_values['products_name'] . '</option>';

} else {

echo "\n" . '<option name="' . $products_values['products_name'] . '" value="' . $products_values['products_id'] . '">' . $products_values['products_name'] . '</option>';

}

}

?>

 

 

If that doesn't work for you you may have to alter the table DOCUMENTS to this:

 

DROP TABLE IF EXISTS documents;

CREATE TABLE documents (

documents_id int(11) NOT NULL auto_increment,

language_id int DEFAULT '1' NOT NULL,

documents_description varchar(128) default NULL,

documents_file_name varchar(64) default NULL,

documents_file_size int(11) default NULL,

PRIMARY KEY (documents_id, language_id),

KEY idx_documents_file_name (documents_file_name)

);

 

I have reformed the table for the future incorporation of languages. I am looking at the products extra fields contribution and it has the code I need to do this eventually.

Edited by insomniac2

Share this post


Link to post
Share on other sites

Great! It now shows the file name like I wanted, however when I try to associate an inserted file with a product, I get:

 

1062 - Duplicate entry '1' for key 1

 

insert into documents_products(documents_products_id, products_id, documents_id) values ('1', '173', '1')

 

[TEP STOP]

 

 

I only have one product in the database right now, so I don't have duplicates there.....

Share this post


Link to post
Share on other sites

Glad to hear it works for you danitrin.

 

I still have one issue I am trying to resolve. I have spent hours and can't figure it out LOL

 

You know how the proper product now shows up with it's associated document right?

 

Well now my associated documents choice list is not defaulting to the document that is currently associated to the product. It always opens with the same document .. sorta like in alphabetical order or something.

 

Is yours doing this to?

 

I am now trying to get the document that is associated to the product to show up instantly on the list .. but it's driving me nuts LOL

 

please get back to me on this one. If your is working properly I would like to see your code to compare to mine. Thanx.

Edited by insomniac2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×