/** @var \app\properties\AbstractModel $model */ $model = $item->getAbstractModel(); foreach ($model->attributes() as $attr) { $column[$attr] = $model->getPropertyValueByAttribute($attr); } $compares[] = $column; } ?> <table class="table table-striped table-hover table-condensed table-bordered"> <thead> <tr> <th></th> <?php echo array_reduce($products, function ($result, $item) { /** @var \app\modules\shop\models\Product $item */ $html = app\modules\image\widgets\ObjectImageWidget::widget(['viewFile' => '@app/modules/shop/widgets/views/product-compare/img-tpl', 'model' => $item, 'thumbnailOnDemand' => true, 'thumbnailWidth' => 180, 'thumbnailHeight' => 180, 'limit' => 1, 'additional' => ['blank' => 'http://placehold.it/180x180?text=No+image']]); $html .= Html::tag('p', $item->name); $html .= Html::tag('div', \Yii::t('app', 'Price') . ': ' . $item->nativeCurrencyPrice(false, false)); $result .= Html::tag('th', $html) . PHP_EOL; return $result; }, ''); ?> </tr> </thead> <tbody> <?php foreach ($properties as $key => $prop) { $result = '<tr><th>' . $prop . '</th>'; $result .= array_reduce(array_column($compares, $key), function ($result, $item) { $result .= '<td>' . $item . '</td>'; return $result;
?> <?php if (isset($elementNumber)) { if ($elementNumber < ++$counter) { break; } } ?> <div class="col-xs-3"> <?php $url = Url::to(['/shop/product/show', 'model' => $product, 'last_category_id' => $product->main_category_id, 'category_group_id' => $product->category->category_group_id]); ?> <a href="<?php echo $url; ?> " class="thumbnail"> <?php echo app\modules\image\widgets\ObjectImageWidget::widget(['model' => $product]); ?> <div class='name'><?php echo $product->name; ?> </div> </a> </div> <?php } ?> </div> </div> </div>
?> <?php if (isset($elementNumber)) { if ($elementNumber < ++$counter) { break; } } ?> <div class="col-xs-3"> <?php $url = Url::to(['/shop/product/show', 'model' => $product, 'last_category_id' => $product->main_category_id, 'category_group_id' => $product->category->category_group_id]); ?> <a href="<?php echo $url; ?> " class="thumbnail"> <?php echo app\modules\image\widgets\ObjectImageWidget::widget(['model' => $product, 'displayCountPictures' => 1]); ?> <div class='name'><?php echo $product->name; ?> </div> </a> </div> <?php } ?> </div> </div> </div>