Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Master Products - MS2


2394 replies to this topic

#2101 desmoworks

  • Community Member
  • 52 posts
  • Real Name:Anthony
  • Gender:Male

Posted 21 June 2009, 02:59

View PostGeotex, on Jun 21 2009, 02:57 AM, said:

How are you doing? did you solve your problem, and if so, how?

George

Not yet - I put another 4 hours into it the other day, but haven't made it through your whole list of suggestions... I'm totally at a loss! I hope to work on it tomorrow or Monday again.

#2102 Geotex

  • Community Member
  • 626 posts
  • Real Name:George Snell
  • Gender:Male
  • Location:Houston, TX USA

Posted 21 June 2009, 03:03

View Postdesmoworks, on Jun 20 2009, 09:59 PM, said:

Not yet - I put another 4 hours into it the other day, but haven't made it through your whole list of suggestions... I'm totally at a loss! I hope to work on it tomorrow or Monday again.
Sorry I could not be more specific. When you have a working system then move it and it quits, it takes a lot of hunting. Is there anything else you might share about the differences between the packages or servers that I don't know?
GEOTEX from Houston, TX

(George)

#2103 desmoworks

  • Community Member
  • 52 posts
  • Real Name:Anthony
  • Gender:Male

Posted 21 June 2009, 03:08

View PostGeotex, on Jun 21 2009, 03:03 AM, said:

Sorry I could not be more specific. When you have a working system then move it and it quits, it takes a lot of hunting. Is there anything else you might share about the differences between the packages or servers that I don't know?

Pretty much everything is identical... different servers - same host... all mods are the same on both sites. I'm sure it is one tiny thing that I haven't found, but it will be found!

#2104 Geotex

  • Community Member
  • 626 posts
  • Real Name:George Snell
  • Gender:Male
  • Location:Houston, TX USA

Posted 21 June 2009, 03:29

View Postdesmoworks, on Jun 20 2009, 10:08 PM, said:

Pretty much everything is identical... different servers - same host... all mods are the same on both sites. I'm sure it is one tiny thing that I haven't found, but it will be found!
You said you have a templated system. Is it custom or one of the forks floating around, like oscMax or CRE Loaded?
GEOTEX from Houston, TX

(George)

#2105 desmoworks

  • Community Member
  • 52 posts
  • Real Name:Anthony
  • Gender:Male

Posted 21 June 2009, 03:36

View Postdesmoworks, on Jun 21 2009, 03:08 AM, said:

Pretty much everything is identical... different servers - same host... all mods are the same on both sites. I'm sure it is one tiny thing that I haven't found, but it will be found!

It's custom... took a vanilla OSC and modified to remove all tables and get a custom design going.

#2106 desmoworks

  • Community Member
  • 52 posts
  • Real Name:Anthony
  • Gender:Male

Posted 21 June 2009, 03:46

View Postdesmoworks, on Jun 21 2009, 03:36 AM, said:

It's custom... took a vanilla OSC and modified to remove all tables and get a custom design going.

I should back up - the above is on the one that works - the install I'm having trouble with is on a piece of junk purchased template from template monster. I didn't realize how bad it was until I built my own!

#2107 Geotex

  • Community Member
  • 626 posts
  • Real Name:George Snell
  • Gender:Male
  • Location:Houston, TX USA

Posted 21 June 2009, 04:06

View Postdesmoworks, on Jun 20 2009, 10:46 PM, said:

I should back up - the above is on the one that works - the install I'm having trouble with is on a piece of junk purchased template from template monster. I didn't realize how bad it was until I built my own!

last problem I saw was

Quote

Maybe I'm missing it, but when I hit add to cart with the quantity of each slave it correctly adds the slave but also adds the master! I don't want it to add the master!!!

Is this the only problem, or just the current one to solve? You are looking at basically 4 files. Product_info.php, master_products.php, master_listing.php and a small section of application_top.php and maybe a couple of function calls in general.php

The SPPC contribution will cause a lot of headaches because of all the convoluted loops the original author did, and was unfortunately kept by all who followed.

George
GEOTEX from Houston, TX

(George)

#2108 Zappo

  • Community Member
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 29 June 2009, 00:36

After using the contribution "Master Products" for quite a while, I found "Master Products" to be overly complicated and very difficult to use or merge alongside other contributions.
I wrote this new contribution: "Linked Products", (in combination with an other contribution: "Product Types")
you'll get a lot of the same functionality as the "Master Products" contribution.
Maybe worth a look?

The Linked Products Contribution page can be found here: http://addons.oscommerce.com/info/6842
The support Thread can be found here: http://forums.oscommerce.com/index.php?showtopic=339538
Check out my website! shop.crystalcopy.nl


Like Eek said... It never hurts to help!
----------------------------------------

#2109 Geotex

  • Community Member
  • 626 posts
  • Real Name:George Snell
  • Gender:Male
  • Location:Houston, TX USA

Posted 29 June 2009, 01:15

View PostZappo, on Jun 28 2009, 07:36 PM, said:

After using the contribution "Master Products" for quite a while, I found "Master Products" to be overly complicated and very difficult to use or merge alongside other contributions.
I wrote this new contribution: "Linked Products", (in combination with an other contribution: "Product Types")
you'll get a lot of the same functionality as the "Master Products" contribution.
Maybe worth a look?

The Linked Products Contribution page can be found here: http://addons.oscommerce.com/info/6842
The support Thread can be found here: http://forums.oscommerce.com/index.php?showtopic=339538

Do you have any working examples of this contribution on line that one can see how the organization works?
GEOTEX from Houston, TX

(George)

#2110 desmoworks

  • Community Member
  • 52 posts
  • Real Name:Anthony
  • Gender:Male

Posted 02 July 2009, 04:17

Here is where I'm at. In application_top if I run this code:

//Master Products
							// customer adds multiple products from the master_listing page
							case 'add_slave' :
														  reset($HTTP_POST_VARS);
														  while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {
															if (substr($key,0,11) == "Qty_ProdId_") {
															  $prodId = substr($key,11);
															  $qty = $val;
															  if(isset($HTTP_POST_VARS["id_$prodId"]) && is_array($HTTP_POST_VARS["id_$prodId"])) {
																// We have attributes
																$cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$HTTP_POST_VARS["id_$prodId"]))+$qty, $HTTP_POST_VARS["id_$prodId"]);
															  } else {
																// No attributes
																$cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty);
															  }
															}
														  }

														  if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
															$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
														  }

														  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
														  break;
							//Master Products EOF

The master is added when the slave is. Adding standard products works correctly.

If I take out this portion:

if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
															$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
														  }


I can add slave products only with no master (so that is correct), but I can no longer add standard products from product_info.php - I can however add products with no attributes from the product listing page and new_products, etc...

I don't really understand that bit of code, but the problem definitely seems to be related given the function with and without that bit.

Any thoughts on that?

Edited by desmoworks, 02 July 2009, 04:17.


#2111 Zappo

  • Community Member
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 02 July 2009, 13:53

View PostGeotex, on Jun 29 2009, 03:15 AM, said:

Do you have any working examples of this contribution on line that one can see how the organization works?
Nope, Sorry...
There are however a descent number of screenshots included in the package.
Check out my website! shop.crystalcopy.nl


Like Eek said... It never hurts to help!
----------------------------------------

#2112 Geotex

  • Community Member
  • 626 posts
  • Real Name:George Snell
  • Gender:Male
  • Location:Houston, TX USA

Posted 02 July 2009, 21:53

View Postdesmoworks, on Jul 1 2009, 11:17 PM, said:

Here is where I'm at. In application_top if I run this code:

//Master Products


I can add slave products only with no master (so that is correct), but I can no longer add standard products from product_info.php - I can however add products with no attributes from the product listing page and new_products, etc...

I don't really understand that bit of code, but the problem definitely seems to be related given the function with and without that bit.

Any thoughts on that?

Most of your code looks good. I am not sure where the lines you add/remove should go, if at all. Here is my complete Shopping Cart Actions in Application_top.php. remember that $_POST may need to be replaced with $HTTP_POST_VARS, etc. if your code overall has not bee updated to use super globals.

This code is in use in at least 7 production sites, and works. If it does not work in yours, we may need to look elsewhere for problems. If the denuz txt sections cause a problem, remove them.

// Shopping cart actions
  if (isset($_GET['action'])) {
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
	if ($session_started == false) {
	  tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
	}
	if ($_GET['products_set_only']) {
			tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO . '?products_id=' . $_GET['products_master']));
		}	
	if (DISPLAY_CART == 'true') {
	  $goto =  FILENAME_SHOPPING_CART;
	  $parameters = array('action', 'cPath', 'products_id', 'pid');
	} else {
	  $goto = basename($PHP_SELF);
	  if ($_GET['action'] == 'buy_now') {
		$parameters = array('action', 'pid', 'products_id');
	  } else {
		$parameters = array('action', 'pid');
	  }
	}
	switch ($_GET['action']) {
	  // customer wants to update the product quantity in their shopping cart
	  case 'update_product' : for ($i=0, $n=sizeof($_POST['products_id']); $i<$n; $i++) {
								if (in_array($_POST['products_id'][$i], (is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array()))) {
								  $cart->remove($_POST['products_id'][$i]);
// denuz text attr
//								  tep_db_query("delete from customers_basket_text_attributes where products_id = " . tep_get_prid($_POST['products_id'][$i]) . " and session_id = '" . $osCsid . "'");
// eof denuz text attr
								} else {
								  if (PHP_VERSION < 4) {
									// if PHP3, make correction for lack of multidimensional array.
									reset($_POST);
									while (list($key, $value) = each($_POST)) {
									  if (is_array($value)) {
										while (list($key2, $value2) = each($value)) {
										  if (ereg ("(.*)\]\[(.*)", $key2, $var)) {
											$id2[$var[1]][$var[2]] = $value2;
										  }
										}
									  }
									}
									$attributes = ($id2[$_POST['products_id'][$i]]) ? $id2[$_POST['products_id'][$i]] : '';
								  } else {
									$attributes = ($_POST['id'][$_POST['products_id'][$i]]) ? $_POST['id'][$_POST['products_id'][$i]] : '';
								  }
								  $cart->add_cart($_POST['products_id'][$i], $_POST['cart_quantity'][$i], $attributes, false);
								}
							  }
							  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
							  break;
	  // customer adds a product from the products page
	  case 'add_product' :	if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
								$cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$quantity, $_POST['id']);
// denuz text attr
//								tep_db_query("delete from customers_basket_text_attributes where products_id = " . $_POST['products_id'] . " and session_id = '" . $osCsid . "'");
//								$attr_query = tep_db_query("select * from products_text_attributes_enabled where products_id = " . $_POST['products_id']);
//								while ($attr = tep_db_fetch_array($attr_query)) {
//								  tep_db_query("insert into customers_basket_text_attributes values ('$osCsid', " . $_POST['products_id'] . ", " . $attr['products_text_attributes_id'] . ", '" . addslashes($_POST['products_text_attributes_' . $attr['products_text_attributes_id']]) . "');");
								}
// eof denuz text attr
							  }
							  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
							  break;
	 //Master Products
	 // customer adds multiple products from the master_listing page
	  case 'add_slave' :
							  reset($_POST);
							  while ( list( $key, $val ) = each( $_POST ) ) {
								if (substr($key,0,11) == "Qty_ProdId_") {
								  $prodId = substr($key,11);
								  $qty = $val;
								  if(isset($_POST["id_$prodId"]) && is_array($_POST["id_$prodId"])) {
									// We have attributes
									$cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$_POST["id_$prodId"]))+$qty, $_POST["id_$prodId"]);
								  } else {
									// No attributes
									$cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty);
								  }
								}
							  }
							  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
							  break;
	 //Master Products EOF
	  // performed by the 'buy now' button in product listings and review page
	  case 'buy_now' :		if (isset($_GET['products_id'])) {
								if (tep_has_product_attributes($_GET['products_id'], (int)$languages_id)) {
								  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['products_id']));
								} else {
								  $cart->add_cart($_GET['products_id'], $cart->get_quantity($_GET['products_id'])+1);
								}
							  }
							  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
							  break;
	  case 'notify' :		 if (tep_session_is_registered('customer_id')) {
								if (isset($_GET['products_id'])) {
								  $notify = $_GET['products_id'];
								} elseif (isset($_GET['notify'])) {
								  $notify = $_GET['notify'];
								} elseif (isset($_POST['notify'])) {
								  $notify = $_POST['notify'];
								} else {
								  tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
								}
								if (!is_array($notify)) $notify = array($notify);
								for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
								  $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");
								  $check = tep_db_fetch_array($check_query);
								  if ($check['count'] < 1) {
									tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
								  }
								}
								tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
							  } else {
								$navigation->set_snapshot();
								tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
							  }
							  break;
	  case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($_GET['products_id'])) {
								$check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $_GET['products_id'] . "' and customers_id = '" . $customer_id . "'");
								$check = tep_db_fetch_array($check_query);
								if ($check['count'] > 0) {
								  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $_GET['products_id'] . "' and customers_id = '" . $customer_id . "'");
								}
								tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
							  } else {
								$navigation->set_snapshot();
								tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
							  }
							  break;
	  case 'cust_order' :	 if (tep_session_is_registered('customer_id') && isset($_GET['pid'])) {
								if (tep_has_product_attributes($_GET['pid'])) {
								  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['pid']));
								} else {
								  $cart->add_cart($_GET['pid'], $cart->get_quantity($_GET['pid'])+1);
								}
							  }
							  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
							  break;
	}
  }

GEOTEX from Houston, TX

(George)

#2113 jasonabc

  • Community Member
  • 1,963 posts
  • Real Name:Jason
  • Location:London, now Los Angeles

Posted 10 July 2009, 15:59

Hi guys - I have a scenario and am wondering if Master Products (or Linked Products) is the solution?

I need to "attach" a product with another product when an item is purchased? Lets say, for example, that if you buy product A you would also need to buy product B. Is there any way to put both product A and product B into the cart when you click "buy me" on product A?

thanks!

Jason

#2114 Geotex

  • Community Member
  • 626 posts
  • Real Name:George Snell
  • Gender:Male
  • Location:Houston, TX USA

Posted 10 July 2009, 16:31

View Postjasonabc, on Jul 10 2009, 10:59 AM, said:

Hi guys - I have a scenario and am wondering if Master Products (or Linked Products) is the solution?

I need to "attach" a product with another product when an item is purchased? Lets say, for example, that if you buy product A you would also need to buy product B. Is there any way to put both product A and product B into the cart when you click "buy me" on product A?

thanks!

Jason

I am not familiar with linked products. It is too new, and appears to still be in Alpha stage. Master products can do the job, but not out of the box. Once you get it installed and working, you can mod it to sell sets only. I have done that, an example is on my live test site, www.designerdogregistry.com.

You can see the options in Holly Cow category, standard - Master Test Cow, set only - Master Set of Cow Parts. Clicking on any individual part of either will take you to the appropriate Master.

This is a test site, so any purchases made will not be processed.
GEOTEX from Houston, TX

(George)

#2115 Geotex

  • Community Member
  • 626 posts
  • Real Name:George Snell
  • Gender:Male
  • Location:Houston, TX USA

Posted 10 July 2009, 17:16

update, I waited too long to edit. I am in the process of switching all http_*_vars to super globals, so some strange things occasionally happen until the transition is complete. Things do not always work the same on the web as they do on the local site. That is why I have a live test site.
GEOTEX from Houston, TX

(George)

#2116 concorde44

  • Community Member
  • 75 posts
  • Real Name:Seb
  • Location:Nantes, FRANCE

Posted 18 August 2009, 12:53

Hi everybody,
I'm using this contrib for quite a while with success but I need a function I dont know how to do : to link a slave to many master products.
I had to change the query from includes/modules/master_products.php . Original was :
$master_query = tep_db_query("select products_master from " . TABLE_PRODUCTS . " where products_master LIKE '%" . $HTTP_GET_VARS['products_id'] . "%'");
with
$master_query = tep_db_query("select products_master from " . TABLE_PRODUCTS . " where products_master = " . $HTTP_GET_VARS['products_id']);

but with my change the salve product can not be linked to many master products.
I did it because with the original query " LIKE %54% " (54 is an example) it will link the slave to any master with product id like 54 or 254 or 543 etc...

Is there a way to add on the product info page the master products wished like 54, 213, 567 or only separate with space and then have a slave linked to many masters ?

thanks.
Seb
Osc 2.2 MS2

#2117 concorde44

  • Community Member
  • 75 posts
  • Real Name:Seb
  • Location:Nantes, FRANCE

Posted 20 August 2009, 08:42

Hi again!
Found it!

Solution is on the Contribution page of this mod. I added the fix by A4kquattro "Multiple Masters per Slave - Updated SQL"
And works like a charm : multiple masters per slave, even with space separated value.
Osc 2.2 MS2

#2118 mongomike

  • Community Member
  • 54 posts
  • Real Name:Bryan McMichael
  • Gender:Male
  • Location:Wolverhampton, UK

Posted 17 September 2009, 14:11

This is a great contribution. I am however experiencing one problem.

If I have two Masters one with a Product ID of '12344' and another with the Product ID of '344' and then assign one of these masters with a slave for some reason both of these masters end up with this slave.

It would seem that if 2 (or more) masters have the same sequence of numbers then this problem arises.

The problem I have is that I have thousands of products in my store and obviously don't want master products ending up with slave products which have absolutely nothing to do with them.

Apologies if this has been covered before...

Anyone Any Ideas?

#2119 concorde44

  • Community Member
  • 75 posts
  • Real Name:Seb
  • Location:Nantes, FRANCE

Posted 17 September 2009, 14:32

Hi, I had the same problem.
See the 2 above posts from me. I think the answer is here. Have you already tried to modifiy the $master_query ?
Osc 2.2 MS2

#2120 mongomike

  • Community Member
  • 54 posts
  • Real Name:Bryan McMichael
  • Gender:Male
  • Location:Wolverhampton, UK

Posted 18 September 2009, 08:28

View Postconcorde44, on Sep 17 2009, 03:32 PM, said:

Hi, I had the same problem.
See the 2 above posts from me. I think the answer is here. Have you already tried to modifiy the $master_query ?

thanks alot seb works like a charm. Don't suppose you know how to set the masters to have unlimited slaves. I think they can only have 7-10 by default?