Hello,

is it possible to allow other chars for the SKU, other than latin ones?
I tried to insert greek, but due to the function commerce_product_validate_sku_characters

preg_match('!^[A-Za-z0-9_-]+$!', $sku); 

I get an error message.

Thank you.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

Hmm... interesting problem. Currently it's restricted the same way that other machine names are... do you not have this problem for things like node type names as well?

apanag’s picture

Personally i don't mind using latin chars for node types, because i can specify a valid machine name as it appears on the screenshot. So i have a usable name in my own language and a valid machine name for inner use.

However SKUs are a different story. The problem occurred due to a customer's request, in order to use its current codes, instead of assign new ones.

I think that a lot of customers, want to build an e-shop with their current coding system, for efficient reasons.

alexpua’s picture

In russian language I have changed next

return preg_match('!^[А-Яа-пр-юA-Za-z0-9_-]+$!', $sku);

and I can add russian SKU
in rusian first letter is "а" last "я", but "а-я" did not work and I divided it "а-пр-ю"

recidive’s picture

Can't we just get rid of this validation and leaves it up to store admins to take care of their SKUs?

rszrama’s picture

Issue tags: +dcsprint5

Most likely... I suppose the only reason we don't right now is to ensure easy URLs in case the SKU is used there... i.e. limiting spaces. But I don't know why we're enforcing language through that regex. : P

recidive’s picture

Component: Product » Internationalization

I think this is definitely an internationalization issue.

For the path I think we have pathauto rules/filters, for core oness we can just URL encode it and call that done.

pcambra’s picture

Maybe we could rely in transliteration module (http://drupal.org/project/transliteration) as pathauto does.

googletorp’s picture

#4 I agree with

#5 There is no reason why people should use the SKU in a path to the product, they might as well use the product id, like nodes uses the node id. Ids is usually a bit easier to work with, since they have a natural order, and it's even the PK of the product table. This is what commerce does in the admin backend. We can leave it up to the shop owners to decide how they want their SKUs.

I have created a store where we used views to make a display of products with product id as argument. With some custom coding, we created pathalias'es with integrating pathauto and uptained urls with this pattern:

http://example.com/category/subcategory/[product-title]-[product-id]

We had a lot of products with the same title, which was why we added the product id to url.

Anyways, unless commerce core wants to provide a default way of displaying the products, we should just open up the SKU to contain anything. If we do provide a product display, it would be much nicer integrating with pathauto and let the shop owner be able to configure the urls of his products. In any case, we shouldn't rely on the SKU for the product URL or use transliteration to create safe URLs.

mikejoconnor’s picture

I personally think there are many good reasons to use sku as the path. Currently we are building a site that uses ISBN-13 as the sku, and the publisher would like a path of products/[isbn-13]. That being said, I think most anyone who wants to do this, is capable of building a view, panel, etc to do it.

On the other hand, I think that many people who want to enter non-latin skus, shouldn't have to modify the validation. For that reason, I support not placing machine name limitations on the sku field.

mikejoconnor’s picture

Status: Active » Needs review
FileSize
1.57 KB

Here's a patch to get started. It simply removes the sku validation code, but keeps the unique sku code.

recidive’s picture

@mikejoconnor: in the case you outlined, products/[isbn-13] links to the product node, right? So you can setup pathauto to create the URL and make sure it's well encoded for such. I.e. passing this through Transliteration module, etc?

mikejoconnor’s picture

@recidive

Thats really my point, I can think of many reasons to do this, however I think that there are plenty of other ways to achieve this without depending on sku itself. My vote is to remove the alphanumeric validation

rszrama’s picture

Status: Needs review » Fixed

Curious... apparently I committed this already and never marked it "fixed." :-/

Status: Fixed » Closed (fixed)
Issue tags: -dcsprint5

Automatically closed -- issue fixed for 2 weeks with no activity.