Zen Cart Logo
Forums / General Questions / Unique SKU for each attribute?

Unique SKU for each attribute?

Views: 11,370

Results 21 to 40 of 49
28 Nov 2007, 4:53 PM
#21
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Unique SKU for each attribute?

Update!

I have got most of it working now, I guess it's only those two files mention who's making trouble for me now.

In admin it brakes the site, it's only showing parts of the new feature. But if I manually add ID's to the database I get those skus, options and values showing. But I'm not able to add anything from the site.

In the shop I don't get the sku into shopping cart, but the sku field is showing - I guess it's most likely because of wrong placement of code in includes/classes/order.php

I'm still digging into it, but I would really appreciate if anyone could give more specific location for those new inserts (code above and/or below). ;)

28 Nov 2007, 9:58 PM
#22
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Unique SKU for each attribute?

New update, and this time with some files to play with. :)

Seems like I have sorted out most of it, and I have also rewritten it to be multilingual (English and Norwegian included) - and to allow use of prefix on the database tables.

Everything works fine, and the attributes sku is added and shown in shopping cart - and on orders, invoices and packingslips.

For some reason the sku is not showing on the checkout confirmation, so if someone could figure out that it would be great. Maybe something should be added to '../includes/modules/pages/checkout_confirmation/header_php' ??

Also in admin/attributes_controller.php the layout could need some fixing, not even sure the placement is the best (or right) - but its working for now. :)

NOTE! As always, use at your own risk - no guaranty given on anything. ;)

29 Nov 2007, 1:56 AM
#23
aaronn avatar

aaronn

New Zenner

Join Date:
Oct 2007
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

I'm working on a similar mod, but instead of it using an arbitrary "sku" it's going off the product_model, in addition I've made a "hidden" category to put the "child items" in, so you choose an option from the Parent item it will put the "child item id" in the basket based on the option, that way stock is still being kept track of and can be easily modified.

The users never see the child item product info page, just the parent page.

Make sense? I'll post it as soon as I'm done thoroughly testing.
-Aaron

29 Nov 2007, 3:52 PM
#24
ryanf avatar

ryanf

New Zenner

Join Date:
Mar 2007
Posts:
32
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Glad you are getting there. For the checkout confirmation page, this is what I did.

I changed includes/templates/default/templates/tpl_checkout_confirmation_default.php

I modified the table around line 55 to this:

<table id="cartContentsDisplay">
    <tr class="cartTableHeading">
        <th id="ccQuantityHeading"><?php echo TABLE_HEADING_QUANTITY; ?></th>
        <th id="ccProductsHeading"><?php echo TABLE_HEADING_PRODUCTS; ?></th>
        <th id="ccTotalHeading"><?php echo TABLE_HEADING_TOTAL; ?></th>
    </tr>
    <?php // now loop thru all products to display quantity and price 
    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { 
    ?>
    <tr class="<?php echo $order->products[$i]['rowClass']; ?>">
        <td class="cartQuantity"><?php echo $order->products[$i]['qty']; ?> x</td>
        <td class="cartProductDisplay"><?php echo $order->products[$i]['name']; ?>
            <?php // if there are attributes, loop thru them and display one per line
            if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0 ) {
                echo '<ul class="cartAttribsList">';
                $pas = array();
                $list = '';
                for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
                    $list .= '<li>'.$order->products[$i]['attributes'][$j]['option'].': '.nl2br($order->products[$i]['attributes'][$j]['value']).'</li>';
                    $pas[] = $order->products[$i]['attributes'][$j]['products_attributes_id'];
                }
                sort($pas);
                $products_attributes_ids = '';
                for ($x=0; $x<count($pas); ++$x) {
                    $products_attributes_ids .= $pas[$x].'_';
                }
                $products_attributes_ids = trim($products_attributes_ids, "_");
                $get_sku = $db->Execute("select sku from products_attributes_skus where products_id = '".$order->products[$i]['id']."' and products_attributes_ids = '".$products_attributes_ids."'");
                $list = '<li>SKU: '.$get_sku->fields['sku'].'</li>'.$list;
                echo $list;
                echo '</ul>';
            } // endif attribute-info
            ?>
        </td>
        <td class="cartTotalDisplay">
            <?php echo $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']);
            if ($order->products[$i]['onetime_charges'] != 0 ) {
                echo '<br /> ' . $currencies->display_price($order->products[$i]['onetime_charges'], $order->products[$i]['tax'], 1);
            }
            ?>
        </td>
    </tr>
    <?php  }  // end for loopthru all products ?>
</table>

Hope that helps

29 Nov 2007, 5:55 PM
#25
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Yes, I have the exact same code inserted in tpl_checkout_confirmation_default.php and SKU: is showing up, but the number is missing - and I haven't figured out way yet.

1 Dec 2007, 1:07 AM
#26
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Hi Ryan (or someone else) could you try to clarify this part a bit, especial the line:

After the if statement closes that the for loop from above is in

Seems like there's some trouble in this particular file, and I guess it's why the sku is missing on the checkout page.

ryanf:

Next I modified includes/classes/order.php

I added the line:

$pas = array();

> in the function create_add_products()
> and the line: 
> ```php
// build products_attributes_id list to get sku number later
$pas[] = $attributes_values->fields['products_attributes_id'];

At the end of the for loop in the same function that starts with:

for ($j=0, $n2=sizeof($this->products[$i]['attributes']); $j<$n2; $j++) {

> 
> After the if statement closes that the for loop from above is in, I added:
> ```php
// add sku number to attributes
sort($pas);
		
$products_attributes_ids = '';
for ($x=0; $x<count($pas); ++$x) {
	$products_attributes_ids .= $pas[$x].'_';
}
$products_attributes_ids = trim($products_attributes_ids, "_");
$get_sku = $db->Execute("select sku from products_attributes_skus where products_id = '".$this->products[$i]['id']."' and products_attributes_ids = '".$products_attributes_ids."'");
$this->products_ordered_attributes = "\n\tSKU: ".$get_sku->fields['sku']. $this->products_ordered_attributes;

This adds the sku information to the product information in the shopping cart and to be used in places such as invoices.

1 Dec 2007, 2:14 AM
#27
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Hm.. please overlook that last post, maybe I'm in need of some sleep now ...

If includes/classes/order.php wasn't correct, the sku would not have been showing up in the shopping cart either. So there has to be something else missing somewhere ...

25 Jan 2008, 12:42 PM
#28
milojko avatar

milojko

New Zenner

Join Date:
Jan 2008
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Using this mod, when I try to asign an SKU to an already given attribute it keeps saying:
"Attribute Option and Option Value Do NOT Match - Attribute was not added - : TEXT"
I guess I dont need to mention that I didnt tried to add a TEXT attribute ...

Does anybody possibly know what could cause this problem?

25 Jan 2008, 1:29 PM
#29
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Unique SKU for each attribute?

There is some problems with this mod, and I never cared to track those down because I figured out it wasn't doing exactly what I needed anyway.

I needed it to store the attributes SKU on the order, not just show it up, and fixed it in another way with a hack. Not perfect, and somehow risky, but it does the trick as long as there's only one dropdown.

Now we're just waiting for 1.4 and a proper variant/attribute system. ;)

25 Jan 2008, 1:35 PM
#30
milojko avatar

milojko

New Zenner

Join Date:
Jan 2008
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Hi Rune,
Could you show me how you did that?
I desperately need that ...

25 Jan 2008, 1:44 PM
#31
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Unique SKU for each attribute?

I'll see if I can free up some time to write it down soon ...

But the thing AaronN mentioned he was working on above would be better for most of us, but I'm not sure how that went - he became quiet:

http://www.zen-cart.com/forum/showpost.php?p=466879&postcount=23

26 Jan 2008, 6:00 PM
#32
milojko avatar

milojko

New Zenner

Join Date:
Jan 2008
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

C`mon guys, does anyone know what could cause this behaviour?
Wrong db table, prefix, ...?

26 Jan 2008, 6:02 PM
#33
milojko avatar

milojko

New Zenner

Join Date:
Jan 2008
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Sorry, Rune, didnt see your post when I was writing this ... I look forward to it. Youre my last hope!

1 Feb 2008, 11:43 AM
#34
milojko avatar

milojko

New Zenner

Join Date:
Jan 2008
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Hi Rune,
Any updates?

7 Feb 2008, 4:04 PM
#35
milojko avatar

milojko

New Zenner

Join Date:
Jan 2008
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Anybody?

8 Feb 2008, 11:43 AM
#36
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Hi,

as I wrote:

I'll see if I can free up some time to write it down soon ...

But with our babygirl at hospital for a period this hasn't been possible.

Bumping and complaining would not help you, it's only annoying and doesn't inspire us to do anything ... ;)

8 Feb 2008, 11:52 AM
#37
milojko avatar

milojko

New Zenner

Join Date:
Jan 2008
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Really sorry to hear that, Rune.
I understand, as I too have a babygirl (18 months old).
I didn`t want to sound complaining, really...

11 Feb 2008, 9:36 PM
#38
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Maybe you should take a look at openfreeway.com, it has better support for variants (attributes) - including sku and inventory.

12 Feb 2008, 4:12 PM
#39
milojko avatar

milojko

New Zenner

Join Date:
Jan 2008
Posts:
11
Plugin Contributions:
0

Re: Unique SKU for each attribute?

Oh, I wish I saw this a few months ago. Now its too late, coz a lot of work has been made. But I really didnt expect such a famous ecommerce software not to have such a basic feature ... :(

15 Feb 2008, 9:37 AM
#40
etrader avatar

etrader

New Zenner

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

Re: Unique SKU for each attribute?

milojko:

Using this mod, when I try to asign an SKU to an already given attribute it keeps saying:
"Attribute Option and Option Value Do NOT Match - Attribute was not added - : TEXT"
I guess I dont need to mention that I didnt tried to add a TEXT attribute ...

Does anybody possibly know what could cause this problem?

I am having the exact same issue. Does anybody have a solution to this?