Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Several Random Products


Guest

Recommended Posts

you are missing some instructions--there is probably an sql to run, and it is not included. Also, there is no instruction for what to add to admin--can you add more complete manual instructions? Thanks

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

No sql modifications and no admin modifications. It pretty much takes advantage of what is there already.

 

you are missing some instructions--there is probably an sql to run, and it is not included. Also, there is no instruction for what to add to admin--can you add more complete manual instructions? Thanks
Link to comment
Share on other sites

Hi Roy,

 

thanks for this contribution. :thumbsup: Got it working fine but...

 

there is always something that could be improved...

 

I'm using the imagemagic contribution and would need to get the image properties with tep_image. Had a look at how things work but to be honest, I couldn't figure out.

 

Any idea on how to integrate this? The small images look awful if they don't go through this thumbnail contribution.

 

Take a look at my site: www.finefoods24.com

 

abra

The First Law of E-Commerce: If the user can't find the product, the user can't buy the product.

 

Feedback and suggestions on my shop welcome.

 

Note: My advice is based on my own experience or on something I read in these forums. No guarantee it'll work for you! Make sure that you always BACKUP the database and the files you are going to change so that you can rollback to a working version if things go wrong.

Link to comment
Share on other sites

I dont seem to have TABLE_FEATURED in any of my osc databases--so this makes it not work--this is why I thought I must need an sql query to run--any advice?

 

Here is the error I receive on the page:

1146 - Table 'mindzeye_osc5.TABLE_FEATURED' doesn't exist

select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name from products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join products_description pd on p.products_id = pd.products_id and pd.language_id = '1' left join specials s on p.products_id = s.products_id left join TABLE_FEATURED f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand() limit 10

[TEP STOP]

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

well--I figured if I leave this step out it works fine:

5a. At the top, locate the following lines:
$random_products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' order by rand() limit "  . MAX_RANDOM_SELECT_SPECIALS);
//$random_products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand() limit "  . MAX_RANDOM_SELECT_SPECIALS);

Comment out the first line and uncomment the second line

Edited by rabbitseffort

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

for others that wish to hide the price--remove this line:

 

$random_products_script .= 'else span.innerHTML = price;' . "\n";

 

then the price will not show

 

Thanks for this contribution!--does it work ok with all browsers?

Edited by rabbitseffort

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

this is sort of along Ulrike's question--is there a way to set these lines to be more specific--so maybe they only calculate one size not both? Or to set the sizes? I guess they get pulled from here:

tep_image(DIR_WS_IMAGES . $f['products_image'], '', SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);

 

$random_products_script .= 'img.width = w;' . "\n";

$random_products_script .= 'img.height = h;' . "\n";

Edited by rabbitseffort

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

this is sort of along Ulrike's question--is there a way to set these lines to be more specific--so maybe they only calculate one size not both? Or to set the sizes? I guess they get pulled from here:

tep_image(DIR_WS_IMAGES . $f['products_image'], '', SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);

 

$random_products_script .= 'img.width = w;' . "\n";

$random_products_script .= 'img.height = h;' . "\n";

 

The tep_image appears to do nothing at all in the code. If this could be used, then my images would be processed via imagemagic first. I tried to put this in a few lines down in the code where it says DIR_WS_IMAGES but that only made the images disappear. In the browser view source I see that the normal <img src=.... /> is created but this contribution doesn't like the complete html tag. Tried to strip it but that still doesn't process them properly. I think they really must go via tep_image.

 

I also had a problem with the image height as this is set to 0 in order for the imagemagic thumbnails to work properly. I entered the absolute value instead. Same goes for the table height.

 

Any way to display the product name as well?

 

abra

The First Law of E-Commerce: If the user can't find the product, the user can't buy the product.

 

Feedback and suggestions on my shop welcome.

 

Note: My advice is based on my own experience or on something I read in these forums. No guarantee it'll work for you! Make sure that you always BACKUP the database and the files you are going to change so that you can rollback to a working version if things go wrong.

Link to comment
Share on other sites

Hi,

 

Yeah, if you want to use the automatic thumbnail contribution, you can change this line:

$random_products_script .= 'img.src = src;' . "\n";

 

to:

$random_products_script .= 'img.src = 'product_thumb.php?img=images/' + src + '&w=' + w + '&h=' + h + '" width="' + w + '" height="' + h;' . "\n";

 

Roy

 

 

Hi Roy,

 

thanks for this contribution. :thumbsup: Got it working fine but...

 

there is always something that could be improved...

 

I'm using the imagemagic contribution and would need to get the image properties with tep_image. Had a look at how things work but to be honest, I couldn't figure out.

 

Any idea on how to integrate this? The small images look awful if they don't go through this thumbnail contribution.

 

Take a look at my site: www.finefoods24.com

 

abra

Link to comment
Share on other sites

Sorry, that line should be:

 

$random_products_script .= "img.src = 'product_thumb.php?img=images/' + src + '&w=' + w + '&h=' + h + '\" width=\"' + w + '\" height=\"' + h;\n";

 

Hi,

 

Yeah, if you want to use the automatic thumbnail contribution, you can change this line:

$random_products_script .= 'img.src = src;' . "\n";

 

to:

$random_products_script .= 'img.src = 'product_thumb.php?img=images/' + src + '&w=' + w + '&h=' + h + '" width="' + w + '" height="' + h;' . "\n";

 

Roy

Link to comment
Share on other sites

I've tested it with firefox and ie on windows. The scriptaculous scripts should work with everything, but I'm not so sure about my code :) But my stuff is a very simple so I can't see it being a problem.

 

Roy

 

for others that wish to hide the price--remove this line:

 

$random_products_script .= 'else span.innerHTML = price;' . "\n";

 

then the price will not show

 

Thanks for this contribution!--does it work ok with all browsers?

Link to comment
Share on other sites

argh, teach me for typing too fast!

 

Again, it should be:

$random_products_script .= "img.src = 'product_thumb.php?img=images/' + src + '&w=' + w + '&h=' + h\n";

 

Sorry, that line should be:
Link to comment
Share on other sites

Hi abra,

 

Modify:

$random_products_script .= 'if ( sprice.length > 0 ) span.innerHTML = sprice;' . "\n";

$random_products_script .= 'else span.innerHTML = price;' . "\n";

 

to:

$random_products_script .= "if ( sprice.length > 0 ) span.innerHTML = name + ' ' + sprice;\n";

$random_products_script .= "else span.innerHTML = name + ' ' + price;\n";

 

 

The tep_image appears to do nothing at all in the code. If this could be used, then my images would be processed via imagemagic first. I tried to put this in a few lines down in the code where it says DIR_WS_IMAGES but that only made the images disappear. In the browser view source I see that the normal <img src=.... /> is created but this contribution doesn't like the complete html tag. Tried to strip it but that still doesn't process them properly. I think they really must go via tep_image.

 

I also had a problem with the image height as this is set to 0 in order for the imagemagic thumbnails to work properly. I entered the absolute value instead. Same goes for the table height.

 

Any way to display the product name as well?

 

abra

Link to comment
Share on other sites

abra,

 

actually I have 'On the Fly' Auto Thumbnailer using GD Library on my site and I take advantage of it. I'm not sure how the imagemagic contrib works so perhaps it will help you if I show you how I do it.

 

For OTF, the image src looks like:

product_thumb.php?img=images/picture.gif&w=5&h=5

 

So my javascript looks like:

img.src = 'product_thumb.php?img=images/' + src + '&w=' + w + '&h=' + h;

 

Roy

 

The tep_image appears to do nothing at all in the code. If this could be used, then my images would be processed via imagemagic first. I tried to put this in a few lines down in the code where it says DIR_WS_IMAGES but that only made the images disappear. In the browser view source I see that the normal <img src=.... /> is created but this contribution doesn't like the complete html tag. Tried to strip it but that still doesn't process them properly. I think they really must go via tep_image.

 

I also had a problem with the image height as this is set to 0 in order for the imagemagic thumbnails to work properly. I entered the absolute value instead. Same goes for the table height.

 

Any way to display the product name as well?

 

abra

Link to comment
Share on other sites

Thanks Roy,

 

just needed the hint for where the img tag is created. Started to play around with it and got it working fine now. I even added the title attribute so that you get the tooltip. Product name is displayed, dropped the price.

 

Imagemagic is pretty similar to your OTF thumbnails. It needs this to work:

$random_products_script .= "img.src = 'imagemagic.php?img=' + src + '&w=' + w + '&h=' + h\n";

 

Only thing left is that imagemagic has either image width or image height set in admin configuration. I just put the exact value for image height in the code and that's it. Otherwise it pulls 0 and accordingly is invisible.

 

Again, great contribution, exactly what I was looking for.

 

abra

Edited by abra123cadabra

The First Law of E-Commerce: If the user can't find the product, the user can't buy the product.

 

Feedback and suggestions on my shop welcome.

 

Note: My advice is based on my own experience or on something I read in these forums. No guarantee it'll work for you! Make sure that you always BACKUP the database and the files you are going to change so that you can rollback to a working version if things go wrong.

Link to comment
Share on other sites

what line needs to be added to include product name? Thanks

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

Modify:

$random_products_script .= 'if ( sprice.length > 0 ) span.innerHTML = sprice;' . "\n";

$random_products_script .= 'else span.innerHTML = price;' . "\n";

 

to:

$random_products_script .= "if ( sprice.length > 0 ) span.innerHTML = name + ' ' + sprice;\n";

$random_products_script .= "else span.innerHTML = name + ' ' + price;\n";

 

That would put the name in front of the price. You can add a <br> or any other html text to format it the way you would like.

 

what line needs to be added to include product name? Thanks
Link to comment
Share on other sites

I noticed that the code was wonky on my site and realized that I would need to do the image/text switch in a different way. I could only test this via remote desktop, so I don't know if the transitions are smooth. I know this method works well on my site, but my site is totally different than the vanilla oscommerce I have setup at work for testing.

 

I will be releasing this on monday as a new version on the contributions area.

 

Please replace everything between this two lines:

$random_products_script .= 'function loadRandomProduct() {' . "\n";

 

AND

 

$random_products_script .= '}' . "\n";

 

WIth the following:

$random_products_script .= "Element.hide('randomProductDiv');\n";

$random_products_script .= "var randomProductDiv = document.getElementById('randomProductDiv');\n";

$random_products_script .= 'var href = randomProductArray[randomProductIndex][0];' . "\n";

$random_products_script .= 'var src = randomProductArray[randomProductIndex][1];' . "\n";

$random_products_script .= 'var w = randomProductArray[randomProductIndex][2];' . "\n";

$random_products_script .= 'var h = randomProductArray[randomProductIndex][3];' . "\n";

$random_products_script .= 'var name = randomProductArray[randomProductIndex][4];' . "\n";

$random_products_script .= 'var price = randomProductArray[randomProductIndex][5];' . "\n";

$random_products_script .= 'var sprice = randomProductArray[randomProductIndex][6];' . "\n";

$random_products_script .= 'var loaded = randomProductArray[randomProductIndex][7];' . "\n";

$random_products_script .= "var text = '';\n";

$random_products_script .= "text += '<a href=\"' + href + '\">';\n";

$random_products_script .= "text += '<img src=\"' + src + '\" width=\"' + w + '\" height=\"' + h + '\" border=\"0\" alt=\"' + name + '\" title=\"' + name + '\"';\n";

$random_products_script .= "text += ' onload=\"randomProductArray[' + randomProductIndex + '][7]=true;showRandomProduct()\"';\n";

$random_products_script .= "text += '>';\n";

$random_products_script .= "text += '</a><br>';\n";

$random_products_script .= 'if ( sprice.length > 0 ) text += sprice;' . "\n";

$random_products_script .= 'else text += price;' . "\n";

$random_products_script .= "randomProductDiv.innerHTML = text;\n";

$random_products_script .= 'randomProductIndex++;' . "\n";

$random_products_script .= 'if ( randomProductIndex >= randomProductArray.length ) randomProductIndex = 0;' . "\n";

:blush:

Link to comment
Share on other sites

I did this and all it did was add the price in again--with no name--I have to exclude the price line since it will say $0.00--but I would like the title to show up

 

So I undid these changes--any ideas?

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

Ignore the last post--The above doesnt work for me--however this does--If I do it like this:

 

$random_products_script .= 'if ( sprice.length > 0 ) span.innerHTML = name;' . "\n";
	$random_products_script .= 'else span.innerHTML = name;' . "\n";

 

then the name will show but not the price--exactly what I wanted

 

Thanks again Roy!

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

One other thing I notice is that each page load it will only show 10 products then loop with the same 10 products--is there a way to have it go thru the whole catelog before looping?

 

Not a real big issue I am sure but just a thought

"I must admit that I personally measure success in terms of the contributions an individual makes to her or his fellow human beings."

---Margaret Mead---

 

"The answer is never the answer. What's really interesting is the mystery. If you seek the mystery instead of the answer, you'll always be seeking. I've never seen anybody really find the answer -- they think they have, so they stop thinking. But the job is to seek mystery, evoke mystery, plant a garden in which strange plants grow and mysteries bloom. The need for mystery is greater than the need for an answer.

--Ken Kesey"

Link to comment
Share on other sites

The install file tells you that you can change "Selection of Products on Special".

 

But if you want, you can modify the sql line:

$random_products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' order by rand() limit " . MAX_RANDOM_SELECT_SPECIALS);

 

if you lop off everything after rand() so that it looks like rand()" );, that will select everything.

 

The problem is how big is your catalog? That will generate a LOT of javascript text.

 

Roy

 

One other thing I notice is that each page load it will only show 10 products then loop with the same 10 products--is there a way to have it go thru the whole catelog before looping?

 

Not a real big issue I am sure but just a thought

Link to comment
Share on other sites

  • 1 month later...
Modify:

$random_products_script .= 'if ( sprice.length > 0 ) span.innerHTML = sprice;' . "\n";

$random_products_script .= 'else span.innerHTML = price;' . "\n";

 

to:

$random_products_script .= "if ( sprice.length > 0 ) span.innerHTML = name + ' ' + sprice;\n";

$random_products_script .= "else span.innerHTML = name + ' ' + price;\n";

 

That would put the name in front of the price. You can add a <br> or any other html text to format it the way you would like.

 

 

I have downloaded the V1.1 dated 19 Jun 2006. But I cannot find these 2 lines. Can you help please?

Link to comment
Share on other sites

  • 5 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...