Magento: отображение параметров продукта на странице продукта в виде элементов списка в двух столбцах

Имея фактическую ситуацию с Magento 1.9.3 …

На странице продукта есть много вариантов конфигурации. Необходимо сэкономить место, поэтому нужно превратить вертикальный список опций продукта с одним столбцом в список с двумя столбцами, чтобы уменьшить пространство до 50%.

Уже попробовал несколько методов, также этот:
https://magento.stackexchange.com/questions/70857/display-product-options-change-layout-of-in-block-after-info-column

в комбинации с
Элементы списка Css Styling в двух столбцах

и это
https://csswizardry.com/2010/02/mutiple-column-lists-using-one-ul/

Но не понял это на самом деле. Остановился на результатах, чтобы отобразить все в одной горизонтальной линии. Проблема в том, что если выбрать 10 атрибутов, линия становится очень сжатой и ничего не узнается.

Кто-нибудь там, кто может настроить код?

Вот код, имеющий в:

/template/catalog/product/view/type/options/configurable.phtml

    <?php
$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
$_jsonConfig = $this->getJsonConfig();
$_renderers = $this->getChild('attr_renderers')->getSortedChildren();
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<div class="items">
<dl>
<?php foreach($_attributes as $_attribute): ?>
<?php
$_rendered = false;
foreach ($_renderers as $_rendererName):
$_renderer = $this->getChild('attr_renderers')->getChild($_rendererName);
if (method_exists($_renderer, 'shouldRender') && $_renderer->shouldRender($_attribute, $_jsonConfig)):
$_renderer->setProduct($_product);
$_renderer->setAttributeObj($_attribute);
echo $_renderer->toHtml();
$_rendered = true;
break;
endif;
endforeach;

if (!$_rendered):
?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
</div>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $_jsonConfig ?>);
</script>
<?php echo $this->getChildHtml('after') ?>
<?php endif;?>

0

Решение

Без просмотра выходных данных трудно точно знать, что именно вы хотите, но если вы хотите, чтобы параметры были в 2 столбцах, это должно сработать.

.items dl {
display:flex;
flex-wrap: wrap;
}

.items dl .options-wrapper{
width: 50%;
}

//If you want on smaller screens to make them 1 row.

@media screen and (max-width: 768px) {
.items dl .options-wrapper{
width: 100%;
}
}
   <?php
$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
$_jsonConfig = $this->getJsonConfig();
$_renderers = $this->getChild('attr_renderers')->getSortedChildren();
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<div class="items">
<dl>
<?php foreach($_attributes as $_attribute): ?>
<?php
$_rendered = false;
foreach ($_renderers as $_rendererName):
$_renderer = $this->getChild('attr_renderers')->getChild($_rendererName);
if (method_exists($_renderer, 'shouldRender') && $_renderer->shouldRender($_attribute, $_jsonConfig)):
$_renderer->setProduct($_product);
$_renderer->setAttributeObj($_attribute);
echo $_renderer->toHtml();
$_rendered = true;
break;
endif;
endforeach;

if (!$_rendered):
?>
<div class="options-wrapper">
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
</div>

<?php endif; ?>
<?php endforeach; ?>
</dl>
</div>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $_jsonConfig ?>);
</script>
<?php echo $this->getChildHtml('after') ?>
<?php endif;?>
0

Другие решения

Других решений пока нет …