protected function validateCombinationSkuProduct($index, &$combination)
    {
        if (!isset($combination['sku'])) {
            return null;
        }

        if ($combination['sku'] === '') {
            return true;
        }

        $updating = $this->getUpdating();

        $product_id = null;

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

        if (mb_strlen($combination['sku']) > 255) {
            $this->setErrorLengthRange("combination.$index.sku", $this->translation->text('SKU'), 0, 255);
            return false;
        }

        if (isset($this->processed_skus[$combination['sku']])) {
            $error = $this->translation->text('SKU must be unique per store');
            $this->setError("combination.$index.sku", $error);
            return false;
        }

        $store_id = $this->getSubmitted('store_id');
        $existing = $this->sku->get(array('sku' => $combination['sku'], 'store_id' => $store_id));

        if (isset($product_id) && isset($existing['product_id']) && $existing['product_id'] == $product_id) {
            $this->processed_skus[$combination['sku']] = true;
            return true;
        }

        if (!empty($existing)) {
            $error = $this->translation->text('SKU must be unique per store');
            $this->setError("combination.$index.sku", $error);
            return false;
        }

        $this->processed_skus[$combination['sku']] = true;
        return true;
    }
protected function validateCombinationSkuProduct($index, &$combination)
    {
        if (!isset($combination['sku'])) {
            return null;
        }

        if ($combination['sku'] === '') {
            return true;
        }

        $updating = $this->getUpdating();

        $product_id = null;

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

        if (mb_strlen($combination['sku']) > 255) {
            $this->setErrorLengthRange("combination.$index.sku", $this->translation->text('SKU'), 0, 255);
            return false;
        }

        if (isset($this->processed_skus[$combination['sku']])) {
            $error = $this->translation->text('SKU must be unique per store');
            $this->setError("combination.$index.sku", $error);
            return false;
        }

        $store_id = $this->getSubmitted('store_id');
        $existing = $this->sku->get(array('sku' => $combination['sku'], 'store_id' => $store_id));

        if (isset($product_id) && isset($existing['product_id']) && $existing['product_id'] == $product_id) {
            $this->processed_skus[$combination['sku']] = true;
            return true;
        }

        if (!empty($existing)) {
            $error = $this->translation->text('SKU must be unique per store');
            $this->setError("combination.$index.sku", $error);
            return false;
        }

        $this->processed_skus[$combination['sku']] = true;
        return true;
    }
protected function validateCombinationSkuProduct ( $ index , & $ combination ) { if ( ! isset ( $ combination [ 'sku' ] ) ) { return null ; } if ( $ combination [ 'sku' ] === '' ) { return true ; } $ updating = $ this -> getUpdating ( ) ; $ product_id = null ; if ( isset ( $ updating [ 'product_id' ] ) ) { $ product_id = $ updating [ 'product_id' ] ; } if ( mb_strlen ( $ combination [ 'sku' ] ) > 255 ) { $ this -> setErrorLengthRange ( "combination.$index.sku" , $ this -> translation -> text ( 'SKU' ) , 0 , 255 ) ; return false ; } if ( isset ( $ this -> processed_skus [ $ combination [ 'sku' ] ] ) ) { $ error = $ this -> translation -> text ( 'SKU must be unique per store' ) ; $ this -> setError ( "combination.$index.sku" , $ error ) ; return false ; } $ store_id = $ this -> getSubmitted ( 'store_id' ) ; $ existing = $ this -> sku -> get ( array ( 'sku' => $ combination [ 'sku' ] , 'store_id' => $ store_id ) ) ; if ( isset ( $ product_id ) && isset ( $ existing [ 'product_id' ] ) && $ existing [ 'product_id' ] == $ product_id ) { $ this -> processed_skus [ $ combination [ 'sku' ] ] = true ; return true ; } if ( ! empty ( $ existing ) ) { $ error = $ this -> translation -> text ( 'SKU must be unique per store' ) ; $ this -> setError ( "combination.$index.sku" , $ error ) ; return false ; } $ this -> processed_skus [ $ combination [ 'sku' ] ] = true ; return true ; }
Validates option combination SKUs
@param integer $index
@param array $combination
@return boolean|null
Validates option combination SKUs