Dashes added to SKU within order
-
16-10-2019 - |
Question
Good morning guys,
Something odd I've noticed. When I'm purchasing a configurable product, within the order 3 dashes get added to the SKU.
For example:
A configurable product has the SKU of pickmewine, and the simple product has an SKU of PD101. In the order, the SKU of the actual item ordered becomes PD101---.
Is this normal? If so - how do I reliably remove the dashes? I'm linking into an internal business system and using a str_replace isn't an option as there may be legitimate dashes in an SKU.
Related to this, in the order, I get 2 items for each config products bought. Is using $order->getAllVisibleItems()
the best way around that?
Thanks all
Solution
Check for spaces in the SKU field of your custom options:
See Mage_Catalog_Model_Product_Type_Abstract::getOptionSku()
for the reason why.
OTHER TIPS
We also have this issue. But I noticed that it happens when multiple custom options are chosen at a specific product. The SKU fields are all empty so no spaces are filled in and no dashes should be added. But if the customer uses the checkboxes to add 2 options from one custom option then 2 dashes are added. When customer selects 3 values from one custom option then 3 dashes are added.
We fixed it by not using checkboxes but for some custom options it would be nice to add several values (repair service for instance).
I found somewhere that changing in
app/code/core/Mage/Catalog/Model/Product/Type/<yourtype>.php
the function
public function getOptionSku($optionValue, $skuDelimiter)
{
return '';
}
But I think changing this will have effect on different locations...
Kind regards,
Sander