public function actionGetAttributeValues($attributeId)
    {
        if (\Yii::$app->request->isAjax) {
            $attributeValues = ShopAttributeValue::find()
                ->where(['attribute_id' => $attributeId])->all();

            $attributeValuesArray = ArrayHelper::toArray($attributeValues, [
                'bl\cms\shop\common\entities\ShopAttributeValue' => [
                    'id',
                    'attribute_id',
                    'translation' => 'translation'
                ]
            ]);

            $shopAttribute = ShopAttribute::findOne($attributeId);
            if ($shopAttribute->type_id == ShopAttribute::TYPE_TEXTURE || $shopAttribute->type_id == ShopAttribute::TYPE_COLOR) {
                $newArray = [];
                foreach ($attributeValuesArray as $attributeValuesItem) {

                    $texture = ShopAttributeValueColorTexture::findOne($attributeValuesItem['translation']['value']);
                    if ($shopAttribute->type_id == ShopAttribute::TYPE_TEXTURE) {
                        $texture = $texture->attributeTexture . Html::tag('p', $texture->title);
                    } else if ($shopAttribute->type_id == ShopAttribute::TYPE_COLOR) {
                        $texture = $texture->attributeColor . Html::tag('p', $texture->title);
                    }

                    $attributeValuesItem['translation'] =
                        array_replace($attributeValuesItem['translation'], ['value' => $texture]);
                    $newArray[] = $attributeValuesItem;
                }
                $attributeValuesArray = $newArray;
            }
            return json_encode($attributeValuesArray);
        } else throw new NotFoundHttpException();
    }
public function actionGetAttributeValues($attributeId)
    {
        if (\Yii::$app->request->isAjax) {
            $attributeValues = ShopAttributeValue::find()
                ->where(['attribute_id' => $attributeId])->all();

            $attributeValuesArray = ArrayHelper::toArray($attributeValues, [
                'bl\cms\shop\common\entities\ShopAttributeValue' => [
                    'id',
                    'attribute_id',
                    'translation' => 'translation'
                ]
            ]);

            $shopAttribute = ShopAttribute::findOne($attributeId);
            if ($shopAttribute->type_id == ShopAttribute::TYPE_TEXTURE || $shopAttribute->type_id == ShopAttribute::TYPE_COLOR) {
                $newArray = [];
                foreach ($attributeValuesArray as $attributeValuesItem) {

                    $texture = ShopAttributeValueColorTexture::findOne($attributeValuesItem['translation']['value']);
                    if ($shopAttribute->type_id == ShopAttribute::TYPE_TEXTURE) {
                        $texture = $texture->attributeTexture . Html::tag('p', $texture->title);
                    } else if ($shopAttribute->type_id == ShopAttribute::TYPE_COLOR) {
                        $texture = $texture->attributeColor . Html::tag('p', $texture->title);
                    }

                    $attributeValuesItem['translation'] =
                        array_replace($attributeValuesItem['translation'], ['value' => $texture]);
                    $newArray[] = $attributeValuesItem;
                }
                $attributeValuesArray = $newArray;
            }
            return json_encode($attributeValuesArray);
        } else throw new NotFoundHttpException();
    }
public function actionGetAttributeValues ( $ attributeId ) { if ( \ Yii :: $ app -> request -> isAjax ) { $ attributeValues = ShopAttributeValue :: find ( ) -> where ( [ 'attribute_id' => $ attributeId ] ) -> all ( ) ; $ attributeValuesArray = ArrayHelper :: toArray ( $ attributeValues , [ 'bl\cms\shop\common\entities\ShopAttributeValue' => [ 'id' , 'attribute_id' , 'translation' => 'translation' ] ] ) ; $ shopAttribute = ShopAttribute :: findOne ( $ attributeId ) ; if ( $ shopAttribute -> type_id == ShopAttribute :: TYPE_TEXTURE || $ shopAttribute -> type_id == ShopAttribute :: TYPE_COLOR ) { $ newArray = [ ] ; foreach ( $ attributeValuesArray as $ attributeValuesItem ) { $ texture = ShopAttributeValueColorTexture :: findOne ( $ attributeValuesItem [ 'translation' ] [ 'value' ] ) ; if ( $ shopAttribute -> type_id == ShopAttribute :: TYPE_TEXTURE ) { $ texture = $ texture -> attributeTexture . Html :: tag ( 'p' , $ texture -> title ) ; } else if ( $ shopAttribute -> type_id == ShopAttribute :: TYPE_COLOR ) { $ texture = $ texture -> attributeColor . Html :: tag ( 'p' , $ texture -> title ) ; } $ attributeValuesItem [ 'translation' ] = array_replace ( $ attributeValuesItem [ 'translation' ] , [ 'value' => $ texture ] ) ; $ newArray [ ] = $ attributeValuesItem ; } $ attributeValuesArray = $ newArray ; } return json_encode ( $ attributeValuesArray ) ; } else throw new NotFoundHttpException ( ) ; }
Return attribute values by ajax request.

@param $attributeId
@return string
@throws NotFoundHttpException
Return attribute values by ajax request .