Forums / Templates, Stylesheets, Page Layout / product_model based on attributes

product_model based on attributes

Locked
Results 1 to 17 of 17
This thread is locked. New replies are disabled.
19 Jul 2006, 17:13
#1
milksamsa avatar

milksamsa

New Zenner

Join Date:
Dec 2005
Posts:
33
Plugin Contributions:
0

product_model based on attributes

I'm in desperate need of modding my 1.2.x zen store in order to insert in the ORDERS table a custom products_model related to the attribute bought by customers....

Let's say I sell T-shirts:

Products:
V-shaped Tshirts: product_model field is filled with "001"
Round-neck Tshirts: product_model field is filled with "002"

Attributes might be:
Red (an additional attribute_model field is filled with "red")
Green (an additional attribute_model field is filled with "green")

I would like the product_model stored in the Orders table to be "001red" if a customer decides to buy a red V-shaped tshirt.

Could someone please help me find out which files to modify or at least point me to the right direction?

Thanks to everyone in advance!

Milk.
20 Jul 2006, 03:29
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Posts:
31,500
Plugin Contributions:
4

Re: product_model based on attributes

What you want is "stock by attribute" and this is not a current feature of Zen Cart.

Supposed to be added in a later release. No solution for the time being.
20 Jul 2006, 10:21
#3
milksamsa avatar

milksamsa

New Zenner

Join Date:
Dec 2005
Posts:
33
Plugin Contributions:
0

Re: product_model based on attributes

Maybe somebody could help me find the proper page to modify...
Where does the "Insert" into ORDERS table occur?
There I might populate the products_model field with the result of (eg.):

Whole_products_model=("Products.products_model" + "Attributes.product_model").
20 Jul 2006, 13:28
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Posts:
31,500
Plugin Contributions:
4

Re: product_model based on attributes

Search here for "stock by attributes" for additional detail
20 Jul 2006, 14:02
#5
milksamsa avatar

milksamsa

New Zenner

Join Date:
Dec 2005
Posts:
33
Plugin Contributions:
0

Re: product_model based on attributes

Thank you Kobra, but I guess I JUST need to know where the INSERT statement takes place...that's all...

I don't need to check the level of stocks by attribute...
Does anybody know where does INSERT INTO ORDERS take place?

e.
21 Jul 2006, 05:52
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Posts:
21,876
Plugin Contributions:
6

Re: product_model based on attributes

You can use the Developer's Toolkit in Admin > Tools to locate the file and line where a particular string occurs. Enter a relevant snippet and select "All Files" to find all instances; then you can bring up promising files to examine more closely.
21 Jul 2006, 07:34
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: product_model based on attributes

milksamsa:

Thank you Kobra, but I guess I JUST need to know where the INSERT statement takes place...that's all...

I don't need to check the level of stocks by attribute...
Does anybody know where does INSERT INTO ORDERS take place?

e.

This is done in the order class ... includes/classes/order.php
21 Jul 2006, 13:02
#8
milksamsa avatar

milksamsa

New Zenner

Join Date:
Dec 2005
Posts:
33
Plugin Contributions:
0

Re: product_model based on attributes

I guess the best place to force the products_model to be different would be:

$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$this->products[$index] = array('qty' => $products[$i]['quantity'],
'name' => $products[$i]['name'],
'model' => $products[$i]['model'],
'tax' => ..........

Am I right?



BTW, what's the tag to display text as code in posts?

e.
23 Jul 2006, 03:55
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: product_model based on attributes

No.
Look in the create_add_products element for something like: [PHP] 'products_model' => $this->products[$i]['model'],
[/PHP]




BBedit code for code is [] around CODE or for PHP, is [] around PHP.
24 Jul 2006, 11:13
#10
milksamsa avatar

milksamsa

New Zenner

Join Date:
Dec 2005
Posts:
33
Plugin Contributions:
0

Re: product_model based on attributes

Dear DrByte,
thank you for your support!

I've been trying, before reading your reply, to add a string to the product_model in the section I previously highlighted in my post with success.

I obtained a "3310test" code properly saved in the orders table.

What I did is to write something like this...

$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$this->products[$index] = array('model' => $products[$i]['model'] . 'test',

The problem is:

How do I force, instead of the word "test", the product's corresponding attribute which should have been saved in the cart SESSION, to be saved? how do I refer to it?

I somehow managed to obtain the corresponding attribute later down the code, after the attributes table has been queried:

if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
$attr_value = $products[$i]['attributes_values'][$option];
} else {
$attr_value = $attributes->fields['products_options_values_name'];

immediately after this block I would add...
$this->products[$index] = array ('model' => $products[$i]['model'] . $attr_value);

But this overwrites all the data in the array, and the resulting INSERT works only partially.

All data in the array is destroyed except the model part.
How can I update the array, without losing all other information?

Thanks in advance! I'm almost done, and really need to complete this mod!

Milk.
07 Sep 2006, 09:10
#11
svanis avatar

svanis

Zen Follower

Join Date:
May 2005
Posts:
145
Plugin Contributions:
0

Re: product_model based on attributes

I just love to see this thread. Any progress on this?
07 Sep 2006, 09:17
#12
masterblaster avatar

masterblaster

Totally Zenned

Join Date:
Aug 2004
Posts:
528
Plugin Contributions:
0

Re: product_model based on attributes

Try using instead of:
[PHP]$this->products[$index] = array ('model' => $products[$i]['model'] . $attr_value);[/PHP]

this:
[PHP]$this->products[$index]['model'] = $products[$i]['model'] . $attr_value;[/PHP]
It only updates the model part. I would love to see a link to your site when this is ready!
07 Sep 2006, 09:19
#13
milksamsa avatar

milksamsa

New Zenner

Join Date:
Dec 2005
Posts:
33
Plugin Contributions:
0

Re: product_model based on attributes

That was exactly what I've been doing! It worked like a charm.... the site is almost ready... I will post the link as soon as it's online. It is a matter of days. Thx!
19 Sep 2006, 17:42
#14
duncdamonk avatar

duncdamonk

New Zenner

Join Date:
Sep 2006
Posts:
8
Plugin Contributions:
0

Re: product_model based on attributes

A question I would have is what if I want to add the attribute before the model and have it based on attribute conditions. For example:

I have different sizes 1in, 1.5in, 2in. If I did it the way proposed, I get modelx1in. Obviously it's easy to reverse but I want it to display instead of 1in, 100 and instead of 1.5, 150 and so on.

I tried with this simple if statement but I've had no luck. I'm pretty new to PHP and was wondering if I could get your guys input.

if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
            $attr_value = $products[$i]['attributes_values'][$option];
          } else {
            $attr_value = $attributes->fields['products_options_values_name'];
          }
		  $strModel_100 = "1in";
                  $strDisplay_100 = "100-";
		  if ($attr_value == $strModel_100){
			$this->products[$index]['model'] = $strDisplay_100 . $products[$i]['model']; 
		  } 
21 Sep 2006, 19:45
#15
duncdamonk avatar

duncdamonk

New Zenner

Join Date:
Sep 2006
Posts:
8
Plugin Contributions:
0

Re: product_model based on attributes

I got it sorted

$strModel_100 = "1 in";
		  $strModel_100_display = "100-";
		  $strModel_150 = "1.5 in";
		  $strModel_150_display = "150-";
		  $strModel_200 = "2 in";
		  $strModel_200_display = "200-";
		  $strModel_300 = "3 in";
		  $strModel_300_display = "300-";
		  if ($attr_value == $strModel_100){
			$this->products[$index]['model'] = $strModel_100_display . $products[$i]['model'] . " " . $attr_value; 
		  } 
		  if ($attr_value == $strModel_150){
			$this->products[$index]['model'] = $strModel_150_display . $products[$i]['model'] . " " . $attr_value; 
		  } 
		  if ($attr_value == $strModel_200){
			$this->products[$index]['model'] = $strModel_200_display . $products[$i]['model'] . " " . $attr_value; 
		  } 
		  if ($attr_value == $strModel_300){
			$this->products[$index]['model'] = $strModel_300_display . $products[$i]['model'] . " " . $attr_value; 
		  } 
04 Oct 2006, 01:06
#16
silenceway avatar

silenceway

New Zenner

Join Date:
Nov 2005
Posts:
55
Plugin Contributions:
0

Re: product_model based on attributes

Hi...
how is going this?
is there an example?
Thanks.
Byron H.
04 Oct 2006, 06:23
#17
milksamsa avatar

milksamsa

New Zenner

Join Date:
Dec 2005
Posts:
33
Plugin Contributions:
0

Re: product_model based on attributes

Yes... it is working.... www.eq-onweb.com