Skip to main content
page last edited on 28 May 2018

Increasing sku's length

This article applies to the specific versions of software: X-Cart 5.3.x and earlier
Version: 5.4 and early

This article explains how you can increase sku's length for your products. X-Cart limits sku to 32 characters and if you want to increase this value, you need to write a small mod.

Implementation

  1. Create a module. We create a module with developer ID XCMod and module ID SkuLength.

  2. Default sku's length is defined by this piece of code in the \XLite\Model\Product class (more info about namespaces):

    /**
    * ...
    * @Column (type="string", length=32, nullable=true)
    */
    protected $sku;

    This length=32 bit is what limits the sku's length. In order to change that, we should decorate \XLite\Model\Product class and define this line to contain length=255 piece instead.

    To decorate the class, we create classes/XLite/Module/XCMod/SkuLength/Model/Product.php file with the following content:

    <?php
    namespace XLite\Module\XCMod\SkuLength\Model;

    /**
    * The "product" model class
    */
    abstract class Product extends \XLite\Model\Product implements \XLite\Base\IDecorator
    {
    /**
    * Product SKU
    *
    * @var string
    *
    * @Column (type="string", length=255, nullable=true)
    */
    protected $sku;
    }

That is it. Once you enable this module, your product sku's length will be increased to 255 characters.

Module pack

You can downlad this module pack from here: XCMod-SkuLength-v5_3_0.tar