我的产品以网格格式显示,并直接从此页面购买。它们是带有自定义选项的简单产品。每个选项都是一种颜色。是否有被选择的下拉为相关色时的图像分配给每个产品/颜色组合并显示图像的方法吗?
` <?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid">
<?php endif ?>
<li class="productthumb" item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<a href="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(600); ?>" rel="lightbox" title="<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>" />
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(220); ?>" width="220" height="160" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<h2 class="product-name"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<form action="<?php echo Mage::getBaseUrl(); ?>checkout/cart/add/" method="post" style="display:block; clear:both;">
`
在产品页面(而非类别页面)上,有几种商业模块有望实现此功能。因此,没有现成的简易选项。
出于SKU计数,从类别页面订购和数据库可维护性的考虑,可配置产品可能不是解决之道。
一个简单的解决方法是创建media / swatch / red.jpg,media / swatch / orange.jpg,media / swatch / redgreenstripes.jpg等。然后在前端代码中,拉出与所需选项匹配的色板。对于每种颜色选项,你都需要压缩代码,将其与get-base-dir-media-swatches串联,然后将其弹出到图像标签中。
Blutak和字符串解决方案?是的,但是你不必花一整天的时间编写模块。
感谢IRIS。听起来就像我需要的。您能指出一些示例代码吗?
不容易...现在,在当前项目中,我们在猫页面上显示所有颜色选项,而不是小样本。我们还将ajax quickview用于从cat页面添加到购物车。Google的“ magento自定义选项类别”,您将获得一些用于在页面上放置选择下拉列表的代码,可能会更新价格,并可能破坏数据库,从而拉扯东西。 -到一些色板。stackoverflow.com/questions/3896156/…
我用list.phtml中的代码编辑了问题。我忘了提,我也需要收藏夹的网址,以更新选定的颜色时。