2
バンドル製品とグループ化された製品のオプションを製品リストページに表示しようとしています。バンドルとグループ化された製品オプションを製品リストページに表示
設定可能なプロダクトを表示するスクリプトがインターネット上にありますが、バンドルとグループ化のスクリプトを見つけるのに苦労しています。
基本的には、実際の商品ページを見ているかのように、オプションを正確に表示したいと考えています。
おかげ
バンドル製品とグループ化された製品のオプションを製品リストページに表示しようとしています。バンドルとグループ化された製品オプションを製品リストページに表示
設定可能なプロダクトを表示するスクリプトがインターネット上にありますが、バンドルとグループ化のスクリプトを見つけるのに苦労しています。
基本的には、実際の商品ページを見ているかのように、オプションを正確に表示したいと考えています。
おかげ
は、あなたがそれを上書きしている場合は、あなたのlist.phpファイル内の関数の下にこれら三つを置く
1)以下のコードを試してみてくださいそれ以外の場合は最初にそのファイルのメイジ/カタログ/ブロック?製品/リストを上書き.PHPこの行の後にlist.phtmlファイルの設計/フロントエンド/デフォルト/デフォルト/テンプレート/ catelog /製品/ list.phtmlにコードの下に置く
protected function _getProduct($sku)
{
$_productId = Mage::getModel('catalog/product')->getIdBySku($sku);
if($_productId)
{
return Mage::getModel('catalog/product')->load($_productId);
}
return null;
}
public function getAssociatedProducts($sku)
{
$_product = $this->_getProduct($sku);
$simpleProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
return $simpleProducts;
}
/**
* Set preconfigured values to grouped associated products
*
* @return Mage_Catalog_Block_Product_View_Type_Grouped
*/
public function setPreconfiguredValue($sku) {
$_product = $this->_getProduct($sku);
$configValues = $_product->getPreconfiguredValues()->getSuperGroup();
if (is_array($configValues)) {
$associatedProducts = $this->getAssociatedProducts($sku);
foreach ($associatedProducts as $item) {
if (isset($configValues[$item->getId()])) {
$item->setQty($configValues[$item->getId()]);
}
}
}
return $this;
}
2)
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->getTypeId() == 'grouped'){ ?>
<?php $this->setPreconfiguredValue($_product->getSku()); ?>
<?php $_associatedProducts = $this->getAssociatedProducts($_product->getSku()); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
<table class="data-table grouped-items-table" id="super-product-table">
<col />
<col />
<col width="1" />
<thead>
<tr>
<th><?php echo $this->__('Name') ?></th>
<?php if ($this->getCanShowProductPrice($_product)): ?>
<th class="a-right"><?php echo $this->__('Price') ?></th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php if ($_hasAssociatedProducts): ?>
<?php foreach ($_associatedProducts as $_item): ?>
<?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
<tr>
<td><?php echo $this->htmlEscape($_item->getName()) ?></td>
<?php if ($this->getCanShowProductPrice($_product)): ?>
<td class="a-right">
<?php if ($this->getCanShowProductPrice($_item)): ?>
<?php echo $this->getPriceHtml($_item, true) ?>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('super-product-table')</script>
<?php } ?>
3)
このヘルプがあります。 注:このコードはグループ化された製品にのみ対応しています
解決方法を見つけましたか? – MatheusJardimB