Jump to content
Johnson

Master Products - MS2

Recommended Posts

Hello im using Master Products is it possible to set the sizes in the master product then use the slave products for the colors so the customer picks there size in the master product, then they pick the colors and quanity, then when they click add to cart the size is carried to each color they picked icon14.gif

Share this post


Link to post
Share on other sites

so the different sizes are all different products? Whats to do? Put it in the product description/name/model number/whatever so you know which is which (and so do your customers) then just add the slaves and your all set.

 

Ryan

Edited by ryanf

If I was crafty, this would be a funny signature.

Share this post


Link to post
Share on other sites

Hello Matti et all

 

Good news, :lol:

 

The N to N master slave relationship (aka Master products version 2) is one step closer. THis means you can assign a slave to many masters. Not easy, but possible.

 

I need some expert help to make it work, but here is where we are so far in combining Johnson's contrib with Galen's contrib.

 

The additions need to be used with Master product 1.1.5 files.

 

Please read all post before proceeding with changes. The imperfect way it works now is explained at the end. Thank you.

 

 

 

Step 1- Insert a new table to hold the M-S relationships

SQL query using PHPMY Admin:

 

CREATE TABLE `products_to_master` (

`slave_id` int(11) NOT NULL default '0',

`master_id` int(11) NOT NULL default '0'

);

 

2. in catalog/includes/modules/master_products.php

 

replace

$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_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 . "'";

 

 

WITH

 

$master_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price, pm.master_id, pm.slave_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_MASTER . " pm, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and p.products_id=pm.slave_id and pm.master_id=" . $_GET['products_id'] ;

 

 

Step 3

Corection to add to cart in catalog/includes/application_top.php

 

FIND

// customer adds a product from the products page

case 'add_product' : 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;

 

 

 

After above INSERT/OR REPLACE if case 'add_slave' exists:

 

//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

 

 

 

HOW IT WORKS NOW:

 

a)

Assign a product as a master and assign one slave to it using Johnson's contrib. (If you remove or do not add this slave, the following will not work any more)

 

B)

Using PhPMYAdmin add the master slave relationships you want in the products_to_master table.

 

c)

YOur master product will list all the slaves that you added to the products_to_master table. The Add to cart button will add all of them to the cart.

 

 

THINGS WE NEED HELP WITH:

1. a work around issue a). If there is a relationship in the products_to_master table it should be listed even if we did not assign a slave using Johnson's contrib or if we remove that slave

 

2. A user-friendly admin page where we can assign the slave master relationships in the products_to_master table. It would be excellent if we can assign more slaves/masters at once.

 

3. A friendly admin page where we can change the status of a product from master to slave and from slave to master.

 

That's all. I would say with your help this can be functional and friendly in a few days.

 

Read you soon,

Xena - Xploring 4d ONE :rolleyes:

Share this post


Link to post
Share on other sites

Just a quick addition

 

It is better if the table products_to_master is MyISAM table (As in the original Galen's contrib), which supports concurrent SELECT and INSERT statements:

 

CREATE TABLE `products_to_master` (

`slave_id` int(11) NOT NULL default '0',

`master_id` int(11) NOT NULL default '0'

) TYPE=MyISAM;

Share this post


Link to post
Share on other sites

Sorry... I posted this as a new topic in the general forum too.

 

Is this the correct code to have an input field instead of pull down for quantity in slave listings?

 

echo TEXT_QUANTITY . '  ' . tep_draw_input_field('Qty_ProdId_' . $product_info['products_id'], '', 'size="4"');

 

If so, which file does it go in an what does it replace?

 

Thanks

Share this post


Link to post
Share on other sites

And another thing...

 

Is it possible to add extra product fields, as those added by Product Extra Fields contrib, to the slave listing?

 

Thanks

Edited by swolock

Share this post


Link to post
Share on other sites
Sorry... I posted this as a new topic in the general forum too.

 

Is this the correct code to have an input field instead of pull down for quantity in slave listings?

 

echo TEXT_QUANTITY . '  ' . tep_draw_input_field('Qty_ProdId_' . $product_info['products_id'], '', 'size="4"');

 

If so, which file does it go in an what does it replace?

 

Thanks

The code you found is almost correct. This worked for me:

Change the line:

$lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing['products_id'], $qty_array);

in: includes/modules/master_listing.php

to:

$lc_text = tep_draw_input_field('Qty_ProdId_' . $listing['products_id'], '0', 'size="4"');

This line appears twice, around line 160 and 170 in the section that starts with:

case 'MASTER_LIST_BUY_NOW':

Incidently, this will show "0" in the input field. If you don't want anything in the field use '' instead of '0'.

Share this post


Link to post
Share on other sites

Thanks Jan, this simple solution (previous post) for input boxes instead of pull-downs works great!

Share this post


Link to post
Share on other sites

Re: slave to N master relationships

 

I immediately liked the idea of having slave to N master relationships, since I would like to use it in a site I'm building at the moment.

 

Three remarks: in includes/database_tables.php the line:

 

define('TABLE_PRODUCTS_TO_MASTER', 'products_to_master');

 

should be added.

 

Regarding step 3:

After above INSERT/OR REPLACE if case 'add_slave' exists:

//Master Products ENDLICH ?BERHOLT!! Ren? Reineke 06.12.03 
// customer adds multiple products from the master_listing page
case 'add_slave' :

Inserting:

 reset( $HTTP_POST_VARS );

right after case 'add_slave' works fine too.

 

The biggest problem I got is that I couldn't get the master_sql to work. No products were found. Perhaps it has something to do with the fact that I don't have any manufacturers nor special products.

 

Anyway I didn't want to abandon it right away so I have tinkered with the sql query till it worked. I don't know if it works as it should, but at least it works for me ;-)

 

Perhaps the left joins that are in the original query are important.

 

Anyhow this is what worked for me:

 

$master_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price, pm.master_id, pm.slave_id from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_MASTER . " pm, " . 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_status = '1' AND pd.language_id = '" . (int)$languages_id . "' AND p.products_id=pm.slave_id AND pm.master_id='" . $_GET['products_id'] ."'";

Share this post


Link to post
Share on other sites

Hello. I'm new to all this and was wondering if someone could help me with this issue. I have two questions, but, first some background. I sell perfumes, and, often times, people search by perfume name and bottle size. For example, if you want the 3.4 ounce bottle of Eternity, some people enter "Eternity 3.4" into the search field. So, assuming that I'm making "Eternity" my master, and "3.4" my slave, would the 3.4 ounce slave come up in search results? The reason that I ask is that, with product attributes, the search does NOT return results from the actual attribute.

 

Second question is, will this contribution work with Easy Populate?

 

JP

Share this post


Link to post
Share on other sites

Ok, disregard the previous posts. You must forgive me as I have ZERO PHP programing experience. I've been able to figure out pretty much what I need on my own, but, there are two things that I'm going to need your help with:

 

1) How do I get a text box, rather than a drop down, with a default quantity of "1" to appear next to the slaves? Then, how do I get one "Add to Cart" or "Buy Now" button to appear next to each slave, so that the customer doesn't have to manually change the quantity to "1" then click "Buy Now" at the end of the page? In other words, I want a Buy NOw or Add to Cart button next to each slave product listing.

 

2) How do I get the shopping Cart to show the Master product name, followed by a space, then the slave product name that the person has in their cart? For example:

 

Master product is "Eternity by Calvin Klein"

Slave is "3.4 ounces"

 

Right now, when someone views their cart, all they are seeing is 3.4 ounces, but, how do they know what the perfume is? What I want is for it to read "Eternity by Calvin Klein 3.4 ounces"

 

Please advise. I think I would need to change something in shopping_cart.php

 

JP

Share this post


Link to post
Share on other sites

forgot number 3:

 

3) I would like slave products to display images, but, I want it to default to the master's image. In the above example, if the Master (Eternity) has 3 slaves (3.4 ounces, 1.7 ounces, 1.0 ounce), I want each of the three slaves to display the image from the Master. How do I do this>?

 

Also, I'm getting an error of "product not found" when I try to "Buy now"

 

Any ideas?

Share this post


Link to post
Share on other sites

forgot number 3:

 

3) I would like slave products to display images, but, I want it to default to the master's image. In the above example, if the Master (Eternity) has 3 slaves (3.4 ounces, 1.7 ounces, 1.0 ounce), I want each of the three slaves to display the image from the Master. How do I do this>?

 

Also, I'm getting an error of "product not found" when I try to "Buy now"

 

Any ideas?

Share this post


Link to post
Share on other sites

Forget it, because, I thought of a problem with naming my slaves ONLY the size ("3.4 ounce"), namely with product listings in Froogle and other shopping engines. So, we need to revert to excluding slaves from search results on the website, however, including them in the actual query. Example:

 

Master is "Eternity for ladies"

Slave is "Eternity for ladies, 3.4 ounce"

 

If someone enters "Eternity 3.4" in the search field, I want ONLY the master "Eternity for ladies" to appear in the search results. Is this possible?

 

I also want the image thing (defaulting the slave's image to the master's).

 

JP

Share this post


Link to post
Share on other sites
I would like to a Quantity input box instead of a Quantity dropdown. So what do I need to do to change this in the product_info page.

See page 94, close to the bottom.

Share this post


Link to post
Share on other sites

is it possible to have master products setup like this??

<-! master !->

Product Image

Product Description

 

Product Sizes: dropdown

<- end master ->

<- slaves->

Slaves:

Red Qty box

Black qty box

<-end slaves->

when they customer picks a size then puts numbers next to each color they want can the selected size from the master product be distributed to each slaves (colors) in the Shoppping Cart

 

- Mr Digital-

Edited by mrdigital

Share this post


Link to post
Share on other sites

I would still like Gene's question from a few pages back answered, as I can't find it anywhere (despite Ryan indicating he had answered "2 or 3 pages back"). How can I get a "Buy Now" or "Add to Cart" button to appear next to each slave, with a default quantity of "1" so that ONLY that slave which is next to the "Buy Now" button that is pressed, is added to cart. As opposed to the customer phycally selecting a quantity of "1" then searching for the button somewhere on the page?

 

JP

Share this post


Link to post
Share on other sites

is it possible to have master products setup like this??

<-! master !->

Product Image

Product Description

 

Product Sizes: dropdown

<- end master ->

<- slaves->

Slaves:

Red Qty box

Black qty box

<-end slaves->

when they customer picks a size then puts numbers next to each color they want can the selected size from the master product be distributed to each slaves (colors) in the Shoppping Cart

 

- Mr Digital-

Share this post


Link to post
Share on other sites

I have a question about using Master/Slave with EasyPopulate. In the EP.txt file there are fields from the Product table, but not the Product_id field since it is an autoincrement field. With everything based on the product_model.

 

Now with master/slave in the products_master field you have either a 0 if it is a master, or the product_id of the master if it is a slave. My question is how do you know what the master product_id is going to be, so that you can put it in the products_master field?

 

Kerry.


Kerry Slavin

Share this post


Link to post
Share on other sites

OK, I have found away around the master/slave create problem with easypopulate.

My post above describes the problem "the invisible products_id".

 

What I want is to be able to set the products_id from the easypopulate file so that I know what it is and can use the master ones in the slave rows for the products_master_id column.

 

My Solution.

Modify easypopulate.php to export and import products_id. If products_id is omitted in the import file then use the mysql autoincrement value. One little gotch to watch for is if the first field in an easypopulate import file is empty all the other fields are shifted left. To overcome this, I drop the products_id field in second after the products_model field. This doesn't cause any problem because the script reads these fields into variables and then uses the variable in the right order for the database inserts.

 

In the code below my line numbers will vary somewhat from yours because I am using quantity price breaks plus my own added attribute fields in the products table. So if you substract 10-20 lines cumulatively for each modificaton before my quoted lines you should get close to the place for the modification.

 

At line 210 after 'v_categories_id', insert a new line with;

'v_products_id',

 

At lines 917, 1064, 1110 and 1237 insert after

'v_products_model'  => $iii++,

a new line with;

'v_products_id'    => $iii++,

 

At line 1757 modify;

$sql = "SHOW TABLE STATUS LIKE '".TABLE_PRODUCTS."'";
        $result = tep_db_query($sql);
        $row =  tep_db_fetch_array($result);
        $max_product_id = $row['Auto_increment'];
        if (!is_numeric($max_product_id) ){
         $max_product_id=1;
        }
        $v_products_id = $max_product_id;

 

with the if block wrapper below;

//now we check if the product_id has been set in the uploaded file
        if ($v_products_id == "") {
        $sql = "SHOW TABLE STATUS LIKE '".TABLE_PRODUCTS."'";
        $result = tep_db_query($sql);
        $row =  tep_db_fetch_array($result);
        $max_product_id = $row['Auto_increment'];
        if (!is_numeric($max_product_id) ){
         $max_product_id=1;
        }
        $v_products_id = $max_product_id;
        }

 

At line 1770 modify the INSERT statement from;

$query = "INSERT INTO ".TABLE_PRODUCTS." (
  	 products_image,

to;

$query = "INSERT INTO ".TABLE_PRODUCTS." (
  	 products_id,
  	 products_image,

 

Finally at line 1799 modiy;

VALUES (   	 '$v_products_image',";

 

to;

VALUES (      '$v_products_id',      '$v_products_image',";

 

Now you can control your products_id's while using easypopulate!!! :D

 

Kerry.


Kerry Slavin

Share this post


Link to post
Share on other sites

Have you already tested this? If so, does it work perfectly? By the way, great solution. Thanks a ton, as this saves me a ton of time if it works well, but, I wanted to make sure that it works.

 

JP

Share this post


Link to post
Share on other sites

Has anyone had any issues with searches and manufacture list not working 100%.

 

Searches work fine but when the products are listed the products buy now button has no link so it show no rpoduct once clicked, I have the same issue on manufacturer, as MP is the only extra contrib added to my site I assume this is the problem.

 

Has anyone had this?

 

many thx in advance.


Always seeking & Desperate to find a solution!

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

×