protected function validateSkuProduct()
    {
        $field = 'sku';

        if ($this->isExcluded($field) || $this->isError()) {
            return null;
        }

        $value = $this->getSubmitted($field);
        $label = $this->translation->text('SKU');

        if ($this->isUpdating() && empty($value)) {
            $data = $this->getSubmitted();
            $value = $this->product->generateSku($data);
            $this->setSubmitted('sku', $value);
        }

        if (isset($value) && mb_strlen($value) > 255) {
            $this->setErrorLengthRange($field, $label, 0, 255);
            return false;
        }

        if (!empty($value)) {
            $this->processed_skus[$value] = true;
        }

        $updating = $this->getUpdating();

        if (isset($updating['sku']) && $updating['sku'] === $value) {
            return true;
        }

        $product_id = null;

        if (isset($updating['product_id'])) {
            $product_id = $updating['product_id'];
        }

        $store_id = $this->getSubmitted('store_id');

        if (isset($updating['store_id'])) {
            $store_id = $updating['store_id'];
        }

        $existing = $this->sku->get(array('sku' => $value, 'store_id' => $store_id));

        if (isset($product_id) && isset($existing['product_id']) && $existing['product_id'] == $product_id) {
            return true;
        }

        if (!empty($existing)) {
            $this->setErrorExists($field, $label);
            return false;
        }

        return true;
    }
protected function validateSkuProduct()
    {
        $field = 'sku';

        if ($this->isExcluded($field) || $this->isError()) {
            return null;
        }

        $value = $this->getSubmitted($field);
        $label = $this->translation->text('SKU');

        if ($this->isUpdating() && empty($value)) {
            $data = $this->getSubmitted();
            $value = $this->product->generateSku($data);
            $this->setSubmitted('sku', $value);
        }

        if (isset($value) && mb_strlen($value) > 255) {
            $this->setErrorLengthRange($field, $label, 0, 255);
            return false;
        }

        if (!empty($value)) {
            $this->processed_skus[$value] = true;
        }

        $updating = $this->getUpdating();

        if (isset($updating['sku']) && $updating['sku'] === $value) {
            return true;
        }

        $product_id = null;

        if (isset($updating['product_id'])) {
            $product_id = $updating['product_id'];
        }

        $store_id = $this->getSubmitted('store_id');

        if (isset($updating['store_id'])) {
            $store_id = $updating['store_id'];
        }

        $existing = $this->sku->get(array('sku' => $value, 'store_id' => $store_id));

        if (isset($product_id) && isset($existing['product_id']) && $existing['product_id'] == $product_id) {
            return true;
        }

        if (!empty($existing)) {
            $this->setErrorExists($field, $label);
            return false;
        }

        return true;
    }
protected function validateSkuProduct ( ) { $ field = 'sku' ; if ( $ this -> isExcluded ( $ field ) || $ this -> isError ( ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; $ label = $ this -> translation -> text ( 'SKU' ) ; if ( $ this -> isUpdating ( ) && empty ( $ value ) ) { $ data = $ this -> getSubmitted ( ) ; $ value = $ this -> product -> generateSku ( $ data ) ; $ this -> setSubmitted ( 'sku' , $ value ) ; } if ( isset ( $ value ) && mb_strlen ( $ value ) > 255 ) { $ this -> setErrorLengthRange ( $ field , $ label , 0 , 255 ) ; return false ; } if ( ! empty ( $ value ) ) { $ this -> processed_skus [ $ value ] = true ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'sku' ] ) && $ updating [ 'sku' ] === $ value ) { return true ; } $ product_id = null ; if ( isset ( $ updating [ 'product_id' ] ) ) { $ product_id = $ updating [ 'product_id' ] ; } $ store_id = $ this -> getSubmitted ( 'store_id' ) ; if ( isset ( $ updating [ 'store_id' ] ) ) { $ store_id = $ updating [ 'store_id' ] ; } $ existing = $ this -> sku -> get ( array ( 'sku' => $ value , 'store_id' => $ store_id ) ) ; if ( isset ( $ product_id ) && isset ( $ existing [ 'product_id' ] ) && $ existing [ 'product_id' ] == $ product_id ) { return true ; } if ( ! empty ( $ existing ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } return true ; }
Validates a product SKU
@return boolean|null
Validates a product SKU