2011-09-10 13 views
0

商品ページに表示されているのと同じ方法で商品を挿入して表示することができます(属性、価格、注文ボタンなど...)Magento ecommerce - 製品の詳細を呼び出してCMSページに表示する方法

私は、製品ページのソースコードのコピーされた部分を挿入して単一のページを作成することに成功しましたが、これはかなりのページを処理することを検討していることを考えると、かなり長く手間がかかるプロセスです。

したがって、製品の詳細をCMSページに呼び出せるようにしたいと考えています。

は、あなたのコメントのために、事前にすべてのいただきありがとうございます...私はview.phtmlを使用して所望のCMSページに挿入できると思っていたが、私はどちらかのproduct_idを定義する方法を見つけ出すことができませんでした

このような

答えて

3

うーん、CMSマクロ:

{{block type="catalog/product" template="catalog/product/line-item.phtml" sku_id="CI 101"}}

参照テンプレートカタログ/製品/ラインitem.phtml:

<?php //Template_Name/catalog/product/line-item.phtml 
     //{{block type="catalog/product" template="catalog/product/line-item.phtml" sku_id="CI 100"}} 
     //Feed template SKU for product listing 
?> 

<?php $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->getData('sku_id')); ?> 

<?php /* get special freight messages from custom variables */ 
    $freightfree = Mage::getModel('core/variable')->loadByCode('free_freight_text')->getValue('plain'); 
    $hazmat = Mage::getModel('core/variable')->loadByCode('hazmat_text')->getValue('plain'); 
    $ormd = Mage::getModel('core/variable')->loadByCode('ormd_text')->getValue('plain'); 
?> 

<!-- <div class="single-product"> --> 
<div class="listing-type-list catalog-listing"> 
<div class="listing-item last"> 
    <?php $specialshipping = $_product->getAttributeText('special_shipping_group') ?> 

     <?php // Product Image ?> 
     <div class="product-image"> 
      <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getSmallImageLabel()) ?>"> 
       <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135); ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /> 
      </a> 
     </div> 

     <?php // Product description ?id= echo $_product->getId();?> 
     <div class="product-shop"> 
      <h2><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h5> 
      <?php if($_product->getRatingSummary()): ?> 
      <?php echo $this->getReviewsSummaryHtml($_product) ?> 
      <?php endif; ?> 
      <?php echo $this->getPriceHtml($_product, true) ?> 
      <?php if(!$_product->getNotforsale()): ?> 
       <?php if(!$_product->getReplace_add_button()): ?> 
        <?php if($_product->isGrouped()): ?> 
         <button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('View Selection') ?></span></button> 
        <?php elseif($_product->getHasOptions()): ?> 
         <button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('View Options') ?></span></button> 
        <?php else: ?> 
         <button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button> 
        <?php endif; ?> 
       <?php else: ?> 
        <button class="form-button" onclick="setLocation('<?php echo $_product->getProductUrl() ?>')"><span><?php echo $_product->getAttributeText('replace_add_button') ?></span></button>      
       <?php endif; ?> 
      <?php endif; ?> 
      <div class="clear"></div> 
      <?php /* display special freight messages from custom variables */ ?> 
      <?php if($specialshipping == "Free Ground" || $specialshipping == "Free Gnd ORMD"): ?> 
       <?php echo '<span class="regular-price"><span class="freightfree">' . $freightfree . '</span></span>' ?> 
      <?php endif; ?> 
      <?php if($specialshipping == "ORM-D"): ?> 
       <?php echo '<span class="freightfree">' . $ormd . '</span>' ?> 
      <?php elseif($specialshipping == "Free Gnd ORMD"): ?> 
       <?php echo '<br><span class="freightfree">' . $ormd . '</span>' ?> 
      <?php elseif($specialshipping == "HazMat"): ?> 
       <?php echo '<span class="freightfree">' . $hazmat . '</span>' ?> 
      <?php endif; ?> 
      <div class="description"> 
       <?php echo nl2br($_product->getShortDescription()) ?> 
       <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><small><?php echo $this->__('Learn More') ?></small></a> 
      </div> 
      <p class="add-to"> 
       Brand Name: <?php echo $_product->getBrand() ?> 
      </p> 
     </div> 
</div> 
</div> 

これは、おそらくシステムにはないカスタム属性と変数をいくつか引き出していることに注意してください。あなたが好きなCMSページで何度でも

<?php $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->getData('sku_id')); ?>

使用マクロ:最も重要なのは、マクロのCMS

{{block type="catalog/product" template="catalog/product/line-item.phtml" sku_id="CI 101"}}

と、このラインです。

+0

これを定期的に使用してCMSページを確認してください。誰かがかわいくなり、注意を払わずにカタログからSKUを削除すると、存在しないオブジェクトエラーがスローされます。私は時間がかかるときにそれのためのテストを追加する必要があります。 –

+0

素晴らしい...これはうまくいきました...ありがとうございました;-) –

+0

Hi Fiasco Labs ...カテゴリの説明から同じことをやりたければ、どうすればいいですか?同じコード(CMSページから完全に動作する)を貼り付けると、カテゴリの説明の/からは機能しません。 私が試したのはですが、役に立たないのです 助言してください。 Thx a lot again ;-) –

関連する問題