質問

Magento 1.9 がホームページにカテゴリを追加しないというこの問題について調査しました。そこで、最終的に次のように追加しました。

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="15" template="catalog/product/list.phtml"}}

ホームページのコンテンツへ。ホームページにも表示されますが、次のとおりです。5 つの製品のうち 1 つの製品のみ。それはなぜですか?また、これを変更することはできますか?

私はまだ Magento を使い始めたばかりで、レイアウト部分は何も変更していません。この投稿を見ました: 同じ問題, 、しかし誰も答えてくれませんでした(そして私はそれについてコメントすることができません)、私はフォローしました これらの手順 - しかし、すべてがうまくいきませんでした。

役に立ちましたか?

解決

Magento 1.9 の rwd テーマを使用していますか?その場合は、catalog/product/list.phtml テンプレート ファイルに問題がある可能性があります。

rwd テーマのcatalog/product/list.phtml に次のコードを追加します。

133行目から140行目まで

<?php $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); foreach($_nameAfterChildren as $_nameAfterChildName): $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); $_nameAfterChild->setProduct($_product); ?> <?php echo $_nameAfterChild->toHtml(); ?> <?php endforeach; ?>

そして178行目から186行目まで

<?php //set product collection on after blocks $_afterChildren = $this->getChild('after')->getSortedChildren(); foreach($_afterChildren as $_afterChildName): $_afterChild = $this->getChild('after')->getChild($_afterChildName); $_afterChild->setProductCollection($_productCollection); ?> <?php echo $_afterChild->toHtml(); ?> <?php endforeach; ?>

子ブロック 'name.after' および 'after' を持たずにレイアウトにブロックを追加すると、エラーが発生します。

これをホームページで機能させたい場合は、テーマ内に新しいテンプレート (たとえば、catalog/product/list_home.phtml) を作成し、catalog/product/list.phtml からコードをコピーしますが、次の行からコードを削除する必要があります。と示されている。次に、ホームページ ブロックで新しいテンプレートを使用する必要があります。

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="15" template="catalog/product/list_home.phtml"}}

他のヒント

catalog/product/list.phtml からそれらの線を取り除く

<?php
    //set product collection on after blocks
    $_afterChildren = $this->getChild('after')->getSortedChildren();
    foreach($_afterChildren as $_afterChildName):
        $_afterChild = $this->getChild('after')->getChild($_afterChildName);
        $_afterChild->setProductCollection($_productCollection);
    ?>
    <?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
.

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top