public function generate($pattern, array $options = array())
    {
        $options += array('store_id' => null, 'placeholders' => array());

        $result = null;
        $this->hook->attach('sku.generate.before', $pattern, $options, $result);

        if (isset($result)) {
            return (string) $result;
        }

        $sku = $pattern;
        if (!empty($options['placeholders'])) {
            $sku = gplcart_string_replace($pattern, $options['placeholders'], $options);
        }

        $result = $this->getUnique(mb_strimwidth($sku, 0, 200, ''), $options['store_id']);
        $this->hook->attach('sku.generate.after', $pattern, $options, $result);
        return $result;
    }