Jump to content
Latest News: (loading..)
Johnson

Master Products - MS2

Recommended Posts

When I try add slaves to the cart I have

Your Shopping Cart is empty! (every time) :angry:

 

Why?

I use

Apache 1.3.29

PHP 4.3.4

MySQL 4.0.16

 

at php.ini

register_globals=on

 

Can somebody help?

Share this post


Link to post
Share on other sites
When I try add slaves to the cart I have

Your Shopping Cart is empty! (every time) :angry:

 

Why?

I use

Apache 1.3.29

PHP 4.3.4?

MySQL 4.0.16

 

at php.ini

register_globals=on

 

Can somebody help?

Try to replace function add_slave in catalog/includes/application_top.php

with the following:

 ? ? ?//Master Products ?ENDLICH ?BERHOLT!! Ren? Reineke 06.12.03 ? ? ? ? ? ? ? ? ? ? ? 
? ? ?// customer adds multiple products from the master_listing page
? ? ?case 'add_slave' : ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?foreach ($HTTP_POST_VARS as $keyA => $valueA) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (substr($keyA,0,11) == "Qty_ProdId_") { 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $prodId = substr($keyA,11); 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if ($valueA <= 0 ) continue; 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId, $HTTP_POST_VARS['id']))+($valueA), $HTTP_POST_VARS['id']);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?} 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break; 
? ? ?//Master Products EOF ? ? ?

Worked for me!

Edited by flynst4r

Share this post


Link to post
Share on other sites

Hello, I have a shop with attributes sorter and Mo Pics installed which leaves my admin/catagories.php hacked to hell. My php knowlege is not enough to copy and paste all the Master Products changes into the hacked up file...I was wondering if anyone could help?

Share this post


Link to post
Share on other sites

Hello, I'm new to php; I have been learning very quickly though! I have a problem that I am hoping someone can fix. I added the master slave contribution, and finally got it to play nice with my other contributions; however here is the problem that remains:

I have a master product with 2 slaves (color and sizes). When I select how many of a slave I want, the program only adds the master product and not the slave.

The only way I can add a slave is to click on the slave image, thus opening it's own product page, and then adding to the cart from there.

 

Also, my slave products are showing up in the "New products" box even though they are set no to show in the listing.

 

Thank you folks for all of the contributions and support you have provided. You are helping me reach my dream. I can't express enough how awesome you all are.

 

--Kristy


See you on the dark side,

Kristy

 

I'm just a girl living in captivity

Your rules of thumb makes me worrisome

Share this post


Link to post
Share on other sites
The dropdown quantity selector goes from 0 -> 20 on every product.  This would be more beneficial to go from 0 -> quantity in stock.
I think that it is enough to replace the $lc_text line in the buy_now case in includes/modules/master_listing.php (around lines 163-85) with
            $quantity_select_list = array();
           for ($i = 0, $n2 = (($listing['products_quantity'] < 20) ? $listing['products_quantity'] : 20); $i <= $n2; $i++) {
             $quantity_select_list[] = array('id' => $i, 'text' => $i);
           }
           $lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing['products_id'], $quantity_select_list, '0', 'class="main" style="width: 40px"');

Note that the 20 and the '0' could be replaced by admin settings and that the whole thing could be enclosed in an if statement that selects between the pull_down (code here) and an input field.

 

Hth,

Matt

Share this post


Link to post
Share on other sites
I think that it is enough to replace the $lc_text line in the buy_now case in includes/modules/master_listing.php

This works nicely if you add p.products_quantity to the $master_sql query in master_products.php:

 

 ? ? ?$master_sql = "select ?" . $select_column_list . " p.products_id, ?p.manufacturers_id, p.products_tax_class_id, s.specials_new_products_price, s.status, p.products_quantity, p.products_price from ". TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_id = pd.products_id and p.products_master = '" . $thisquery['products_master'] . "' and p.products_status = '1' and pd.language_id = '" . (int)$languages_id . "'";

 

For those who didn't quite get that, the '20' in Matt's code is the upper limit the drop menu will display - change to the desired setting. Good one :D

Edited by Johnson

Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

Add this in shopping_cart.php to link back to the master product instead of a slave!

## after
     $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

##add this
// Ren? Reineke -- link back to master product on shopping cart      
     $master_prod = tep_db_query("select products_master, products_master_status
                                     from " . TABLE_PRODUCTS . "
                                     where products_id = '" . $products[$i]['id'] . "'");
     $master_prod_values = tep_db_fetch_array($master_prod);
     
     if (($master_prod_values['products_master_status'] == 0) && ($master_prod_values['products_master'] != 0)) {
    	 $products[$i]['id'] = $master_prod_values['products_master'];
     }
// Ren? Reineke MaSTER Mod end

 

creates an extra query. I'm sure it can be optimized but no time now.

Share this post


Link to post
Share on other sites
The dropdown quantity selector goes from 0 -> 20 on every product.? This would be more beneficial to go from 0 -> quantity in stock.
I think that it is enough to replace the $lc_text line in the buy_now case in includes/modules/master_listing.php (around lines 163-85) with
 ? ? ? ? ? ?$quantity_select_list = array();
? ? ? ? ? ?for ($i = 0, $n2 = (($listing['products_quantity'] < 20) ? $listing['products_quantity'] : 20); $i <= $n2; $i++) {
? ? ? ? ? ? ?$quantity_select_list[] = array('id' => $i, 'text' => $i);
? ? ? ? ? ?}
? ? ? ? ? ?$lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing['products_id'], $quantity_select_list, '0', 'class="main" style="width: 40px"');

Note that the 20 and the '0' could be replaced by admin settings and that the whole thing could be enclosed in an if statement that selects between the pull_down (code here) and an input field.

 

Hth,

Matt

Ah, good one - I'll try that a little later.


This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites
This works nicely if you add p.products_quantity to the $master_sql query in master_products.php:
The other change to includes/modules/master_products.php that I forgot to mention was that I commented out (around line 58):
//          $select_column_list .= 'p.products_quantity, ';

Hth,

Matt

Share this post


Link to post
Share on other sites

Any plans to allow a slave to belong to multiple masters? Like if you have a series of gift baskets that use differnt products mostly, but may have some products in common...

Share this post


Link to post
Share on other sites

I made a minor modification of the script to allow me to view which products in the categories.php (/catalog/admin/categories.php) page were designated as "Master" and which were "Slave." Because I entered all my slave products with the same name(s) as the masters, it was impossible to tell with a simple glance at the list.

 

Here are my mods, if anyone's interested:

 

In the master products queries (around line 1420 in my copy) I simply added 'p.products_master_status' to each query:

//Master Products

    $products_count = 0;

    if (isset($HTTP_GET_VARS['search'])) {

      $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_master_status, p.products_listing_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");

    } else {

      $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_master_status, p.products_listing_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");

    }

 

And then changed the table display based on $products['products_master_status'] down around lines 1455 (in my copy - your mileage may vary):

 

                <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product_preview&read=only') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ';

   

  if ($products['products_master_status'] == "1") {

  echo '<span style="color: #00f;">' . $products['products_name'] . ' (Master)</span></td>';

  } else {

  echo $products['products_name'] . '</td>';

  } ?>

 

Now, my products list displays as:

 

Black Leather Studded Belt - Master

Black Leather Studded Belt

Black Leather Studded Belt

 

(Mind you - if I had just entered all my content with a slightly different name for the slave items, I wouldn't have needed to go to this trouble. But I didn't, so I did. So there. :) )

 

 

HOWEVER...

 

Something odd has happened that I don't believe is related to the code I changed. Now, when I click on a product for a quick overview in the box to the right of the list, I get two sets of "Edit/Delete/Move/Copy To" buttons. The top set of buttons appears to relate to the master item - the "Edit" button, for example - while the bottom buttons appear to relate to a standard (slave) item. (See image below:)

 

oscommerce1.gif

 

I really have no idea what's going on. I removed my edits above from the script and the extra buttons were still there. Any ideas?

Share this post


Link to post
Share on other sites
Any plans to allow a slave to belong to multiple masters? Like if you have a series of gift baskets that use differnt products mostly, but may have some products in common...

This simplest way to do this is to use the 'copy' button - then assign another Master to the copied product.

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites
Any plans to allow a slave to belong to multiple masters? Like if you have a series of gift baskets that use differnt products mostly, but may have some products in common...

This simplest way to do this is to use the 'copy' button - then assign another Master to the copied product.

 

Matti

Managing stock becomes an issue then...

Share this post


Link to post
Share on other sites

To have a slave associated with multiple masters, you would have to add a new database table (slaves_to_masters?) which would map between the two. Under the current system, you only have one field in which to store a master's ID. Look at the products_to_categories table for an example of how this would have to work.

 

Hth,

Matt

Share this post


Link to post
Share on other sites

Hi guys. I'm still wondering if anyone can help me with my problem. I can't use the Master Slave contribution until I fix the problem, and boy have I been trying. Okay, here is the problem again:

I have a master product with 3 slaves. When I select how many of a slave I want, the program only adds the master product and not the slave. Additionally, it only adds 1 master, no matter what quantity I select on the slave.

The only way I can add a slave is to click on the slave image, thus opening it's own product page, and then adding to the cart from there.

 

Also, my slave products are showing up in the "New products" box even though they are set no to show in the listing.

 

Please help if you can.

--Kristy


See you on the dark side,

Kristy

 

I'm just a girl living in captivity

Your rules of thumb makes me worrisome

Share this post


Link to post
Share on other sites

Version 1 only has the option to hide Slave products in the categories/ product_listing display.

 

To hide products elsewhere that have 'Hide Product' selected in admin:

 

For the new products box, in catalog/includes/modules/new_products.php change the $new_products_query to:

 

//Products_master
?if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
? ?$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_listing_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
?} else {
? ?$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_listing_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
?}
//Products_master EOF

 

To hide them in the 'What's New' box, in catalog/includes/boxes/whats_new.php change the $random_product query to:

 

//Products_master
?if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' and products_listing_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) {
//Products_master EOF

 

To hide them on the catalog/products_new.php page, update $products_new_query_raw to:

 

//Products_master
?$products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_master, p.products_master_status, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_listing_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
//Products_master EOF

 

(Products do not need a Master to be hidden with the above)

 

The next version of Master Products will probably have a series of check boxes for selecting which pages the individual Slave products will show, including specials, which are not covered above - some users will wish to show Slaves in new products, but not product listing etc.

 

I highly recommend using a program such as Beyond Compare for tracking installation issues.

 

HTH

 

Matti

Edited by Johnson

Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

Ok i figured i would give Master Products a try since it has exactly what i was looking for. I uploaded it to my server and it seemed to cause a bunch of problems. I'm a newbie at PHP so I know its me and not your scripts. But if you guys could help me get back it running correctly I would appreciate it.

 

First problem:

When i go into my Admin Settings. I get this:

admin_mw.jpg

 

1054 - Unknown column 'p.products_listing_status' in 'field list'

 

select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_listing_status from products p, products_description pd, products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = '0' order by pd.products_name

 

[TEP STOP]

 

It's not allowing me to add or modify products or anything along those lines. :o

 

Second Problem:

page_mw.jpg

 

on == true) { if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) { return 0; } } $addresses_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$id . "'"); $addresses = tep_db_fetch_array($addresses_query); return $addresses['total']; } // nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n) function tep_convert_linefeeds($from, $to, $string) { if ((PHP_VERSION < "4.0.5") && is_array($from)) { return ereg_replace('(' . implode('|', $from) . ')', $to, $string); } else { return str_replace($from, $to, $string); } } // //Master Products // grabs a length from a string, but goes back to the last space if it cut into // the middle of a string. If the string is longer than that, cut, then add '...' // to the end of the string, if the $more == 1 function osc_trunc_string($str="",$len=150,$more=1) { if ($str=="") return $str; if (is_array($str)) return $str; $str = trim($str); // if it's less than the size given, then return it if (strlen($str) <= $len) return $str; // else get that size of text $str = substr($str,0,$len); // backtrack to the end of a word if ($str != "") { // check to see if there are any spaces left if (!substr_count($str," ")) { if ($more) $str .= "..."; return $str; } // backtrack while(strlen($str) && ($str[strlen($str)-1] != " ")) { $str = substr($str,0,-1); } $str = substr($str,0,-1); if ($more) $str .= "..."; } return $str; } //Master Products EOF ?>

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/janwdesi/public_html/catalog/includes/functions/general.php:1266) in /home/janwdesi/public_html/catalog/includes/functions/sessions.php on line 67

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/janwdesi/public_html/catalog/includes/functions/general.php:1266) in /home/janwdesi/public_html/catalog/includes/functions/sessions.php on line 67

 

On all of my pages on my website this code comes up on the top of it.

Share this post


Link to post
Share on other sites

Ok i re-uploaded all the files and the only error i get now is in the admin section. The error doesnt show up on my actual webpage untill i go and click on a product.

Edited by rufiogsr

Share this post


Link to post
Share on other sites
Any one know how to fix the 1054 - ERROR?

You must run the master.sql file included in the download on your database - please backup.

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites
Any plans to allow a slave to belong to multiple masters? Like if you have a series of gift baskets that use differnt products mostly, but may have some products in common...

This simplest way to do this is to use the 'copy' button - then assign another Master to the copied product.

 

Matti

Managing stock becomes an issue then...

Ok - I can see this would be a very useful feature - I shall include it in the next release.

 

I have commenced work on version 2, so any further input is much appreciated.

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites
Any one know how to fix the 1054 - ERROR?

You must run the master.sql file included in the download on your database - please backup.

 

Matti

This is defiantly where I messed up. How do I go about running this file on my database? Do I just upload it to any directory and then open the URL to it? Sorry I'm in the learning stages. If someone could please explain further i would appreciate it.

Share this post


Link to post
Share on other sites
Any one know how to fix the 1054 - ERROR?

You must run the master.sql file included in the download on your database - please backup.

 

Matti

This is defiantly where I messed up. How do I go about running this file on my database? Do I just upload it to any directory and then open the URL to it? Sorry I'm in the learning stages. If someone could please explain further i would appreciate it.

Use phpmyadmin - if you have cPanel on your hosting account, go to MySQL databases - there should be a link there to phpmyadmin (down the bottom of the page) - click on this - this usually will open a new window> select your database>depending on your phpmyadmin version, either click on the SQL tab, or simply scroll down the page to the SQL queries dialog>use the browse button to browse to the master.sql file on your local hard drive>click 'go' :D

 

Please backup always before making changes to your database :blink:

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

:rolleyes: Yes, It's me again. I've been working on my website all day (thanks to the help of many people ....Matti you rock). I thought I had it all good and stable about an hour ago, then I did a smoke test for funtionality. Whoops, I have lost the ability to HIDE a slave product. I still have the option to select hide, but it won't save.

 

The only thing (I think) I have done since it was working was change the length of the Product model name in the database. It was 12 before and now it is 20. I don't see how that would effect it though.

 

Any thoughts or suggestions?

 

Thanks,

Kristy


See you on the dark side,

Kristy

 

I'm just a girl living in captivity

Your rules of thumb makes me worrisome

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

×