Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

X5 - Pointers Please for Adding Attribute Codes to SKU

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 04-09-2015, 01:08 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default X5 - Pointers Please for Adding Attribute Codes to SKU

Currently moving a site from v4 to v5.

The v4 site creates a SKU based on product options chosen by the user.

So for example the user chooses
Product Ford Focus - sku is FF
they chose metallic paint upgrade - sku is FF-MET
they chose sat nav upgrade - sku is FF-MET-SAT
and so on..

This is achieved by having a code for every product option in the database and when the product option is chosen some javascript reconstructs the SKU on the page and in a hidden form.

I'm looking at the x5 code for options in admin and have found in XLite/View/Product/Details/Admin/Attributes.php this
Code:
protected function getAttributesList($countOnly = false) { $data = parent::getAttributesList($countOnly); if ($countOnly) { $result = $data; } else { $result = array(); foreach ($data as $attribute) { $result[$attribute->getId()] = array( 'name' => $this->getWidget( $this->getAttributeNameWidgetParams($attribute), '\XLite\View\FormField\Inline\Input\Text' ), 'value' => $this->getWidget( $this->getAttributeValueWidgetParams($attribute), $attribute::getWidgetClass($attribute->getType()) ), ); } } return $result; }

and in the template admin/en/product/attributes/body.tpl
Code:
<li FOREACH="getAttributesList(),id,a" class="line clearfix attribute"> <div class="attribute-name"> {a.name.display()} </div> {a.value.display()} <div IF="isRemovable()" class="actions"> <widget class="XLite\View\Button\Remove" buttonName="delete[{id}]" label="{getPemoveText()}" style="delete" /> </div> </li>

but it's starting to get a little scary how complicated it all is.

Anyone have any pointers about working with this? My second option is to use the option value field to hold the option 'sku' as well as the value and delimit the data. For example...

MET | Metallic Paint
SAT | Sat Nav

and use some PHP or JavaScript to hide the SKU in the select pulldown and use the SKU part in the SKU generation. This option might make it easier for me to export and import the options and their SKUs from the current site.

Any thoughts anyone?
__________________
Core version: 5.5.xx
Reply With Quote
  #2  
Old 04-09-2015, 03:54 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

Hello @xgarb,

First of all, let me please clarify your task a little bit.

As I understood you want to achieve some of points below:

1) Generate SKU for combination of options.

Are you going to use product variants in this case? If this is the case, then you can generate default value for product variant SKU at the point of variants creation and this default SKU value can be generated according to your rules.

2) Generate SKU for combination of product attributes.

The difference from the above is that consumer is not assume to be able to choose product options for the product, but SKU of this product will be automatically generated during this product creation.

Please, let me know if any of points described above makes sense to you.

Also, it would help a ton, if you could explain the mod's business logic first (what result you are trying to achieve) and then, I would be able to suggest a tech solution for this desired functionality.

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #3  
Old 04-09-2015, 06:58 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

The client wants to be able to see the options the customer has chosen either when they have made a purchase or if they are on the phone via the SKU that has been generated.

Most of the client's products have options created as product-specific attributes. On the v4 site as each option is selected it's attribute code is added to the SKU dynamically.

To give a simple example...
http://demostore.x-cart.com/apparel/digital-angel.html
the SKU is 10002 and if a shirt size M is chosen the SKU will be 10002-M

The client's site is a little more complex but this gives the idea.

The client will want to create their own option (attribute) codes. In the current version the client enters attribute name, attribute option(s) and attribute code for each option.
__________________
Core version: 5.5.xx
Reply With Quote
  #4  
Old 04-10-2015, 03:52 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

I've just edited the above message. I forever use the wrong terms for attributes, variants, options etc.

To be clear, on the v4 site the options are set as option groups. On the v5 site they are set as product-specific attributes. Client doesn't want to use the Product Variants as the current system works well for him.
__________________
Core version: 5.5.xx
Reply With Quote
  #5  
Old 04-10-2015, 04:20 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

To get a product with multiple options having their own SKUs you are to use the Product Variants module.
The module adds the ability to specify SKUs for combinations of options and track the inventory against them.

Quote:
Client doesn't want to use the Product Variants as the current system works well for him.

What does the client not like in the Product Variants module?
Is there something that he finds wrong or not easy to use?
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions

Last edited by qualiteam : 04-10-2015 at 06:52 AM.
Reply With Quote

The following user thanks qualiteam for this useful post:
tony_sologubov (04-10-2015)
  #6  
Old 04-10-2015, 04:53 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

Agree with Alex. The whole point of Product Variants is that a product with certain options can have a specific SKU.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #7  
Old 04-10-2015, 07:31 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

He likes the system he has.

It works pretty well on v4.. every option has a code and the SKU is built automatically as the customer chooses their options.

The product variants module is too much work in this case. He doesn't need inventory tracking and with 3000 products, making a sku manually for each option is going to make his head explode.

I've made some progress. I had it working in JavaScript to the point of make the SKU on the product page change as options were selected but realised that there's no easy entry point to saving this to the cart. On v4 there's a PHP function that creates a product from scratch when it's added to the cart and the SKU was created at this point from the chosen options.

I can create the SKU now on the server by hacking about with the Attribute classes but I need some way of getting this created SKU assigned to the product in the cart.
__________________
Core version: 5.5.xx
Reply With Quote
  #8  
Old 04-15-2015, 04:39 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

Thanks for explanation @xgarb. I am still unsure about your business logic though, so I need to dig into your requirements a little further.

Why does your client even need SKU generated for a set of options? Probably they want to use them after an order is already placed (e.g. for getting items from warehouse). In this case, it will be easier for you to hide default SKU field for a product and then add a completely new field that will be saved during adding product to a cart and then displayed on the order page.

So, could you please let me know why your client needs SKU generated for a set of options?

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #9  
Old 04-15-2015, 05:27 AM
 
xgarb xgarb is offline
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

I think it's just easier for them. They know their products and options very well so a string of characters can tell them everything they need to know about a configured product.

They want it to appear in on the product page because a lot of customers will call them when they are on this page.

The car example works well here. If you worked in car dealership and you were given the SKU...

FF-MRED-SAT-2L-ALY-ZN

You'd know it was a Ford Focus with metallic red paint, a sat nav, 2 litre engine, alloy wheels and zenon headlights. They can see at a glance the configured product.

I'm doing ok with the module on the cart page but I'm going round in circles on the product page. I could do it in JavaScript by getting the selected values but I would prefer to use the code in the attribute classes in PHP.
__________________
Core version: 5.5.xx
Reply With Quote
  #10  
Old 04-15-2015, 05:57 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: X5 - Pointers Please for Adding Attribute Codes to SKU

Thanks for explanation.

I feel, the idea of putting logic in PHP is much better than doing such work in JS.

I believe, the main problem for you is to pull list of attributes and the idea of how to achieve that is described here:
http://forum.x-cart.com/showpost.php?p=373343&postcount=15

Please, let me know if it helps.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:42 PM.

   

 
X-Cart forums © 2001-2020