protected function attachSku(array &$product)
    {
        if (empty($product)) {
            return $product;
        }

        $product['default_field_values'] = array();
        $codes = (array) $this->sku->getList(array('product_id' => $product['product_id']));

        foreach ($codes as $code) {

            if ($code['combination_id'] === '') {
                $product['sku'] = $code['sku'];
                $product['price'] = $code['price'];
                $product['stock'] = $code['stock'];
                continue;
            }

            $product['combination'][$code['combination_id']] = $code;

            if (!empty($code['is_default'])) {
                $product['default_field_values'] = $code['fields'];
            }
        }

        return $product;
    }
protected function attachSku(array &$product)
    {
        if (empty($product)) {
            return $product;
        }

        $product['default_field_values'] = array();
        $codes = (array) $this->sku->getList(array('product_id' => $product['product_id']));

        foreach ($codes as $code) {

            if ($code['combination_id'] === '') {
                $product['sku'] = $code['sku'];
                $product['price'] = $code['price'];
                $product['stock'] = $code['stock'];
                continue;
            }

            $product['combination'][$code['combination_id']] = $code;

            if (!empty($code['is_default'])) {
                $product['default_field_values'] = $code['fields'];
            }
        }

        return $product;
    }
protected function attachSku ( array & $ product ) { if ( empty ( $ product ) ) { return $ product ; } $ product [ 'default_field_values' ] = array ( ) ; $ codes = ( array ) $ this -> sku -> getList ( array ( 'product_id' => $ product [ 'product_id' ] ) ) ; foreach ( $ codes as $ code ) { if ( $ code [ 'combination_id' ] === '' ) { $ product [ 'sku' ] = $ code [ 'sku' ] ; $ product [ 'price' ] = $ code [ 'price' ] ; $ product [ 'stock' ] = $ code [ 'stock' ] ; continue ; } $ product [ 'combination' ] [ $ code [ 'combination_id' ] ] = $ code ; if ( ! empty ( $ code [ 'is_default' ] ) ) { $ product [ 'default_field_values' ] = $ code [ 'fields' ] ; } } return $ product ; }
Adds option combinations to the product
@param array $product
@return array
Adds option combinations to the product