belirli kategoriden gösteri ürünler Ben altbilgi için bloğun bir "Ay Ürünü" inşa ediyorum. Bir kategorinin ürünlerini yüklemeli ve ilkini göstermelidir. CMS Page bloğu gömerken catalog/product/list.phtml
Magento: altbilgi
<?php $_productCollection = $this->getLoadedProductCollection() ?>
<div class="featured-product">
<h2><?php echo $this->__('Product of the Month') ?></h2>
<?php foreach ($_productCollection as $_product): ?>
<div class="item">
<a class="product-image" href="<?php echo $_product->getProductUrl() ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(200); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
</a>
<a class="product-name" href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a>
<?php echo $this->getPriceHtml($_product, true) ?>
</div>
<?php
// Note: Exit after first product.
break;
?>
<?php endforeach ?>
</div>
O Magento'nın ürün listesi şablonunun sadece basitleştirilmiş versiyonu:
Bu benim şablon dosyası custom/featured-product.phtml
olduğunu iyi çalışıyor. Örnek: local.xml
aracılığıyla bloğu gömerken
{{block type="catalog/product_list" category_id="13" template="custom/featured-product.phtml" }}
ÇALIŞMA DEĞİL
, başarısız olur. Doğru işaretleme döndürülür, ancak belirtilen kategori yüklenmez. Bunun yerine bir ürün grubunun rastgele (Onların seçilirseniz nasıl yok) yüklenir. local.xml
yılında Kodum: Bütünlüğü için
<default>
<reference name="footer">
<block type="catalog/product_list" name="custom.featuredProduct" as="product_of_the_month" category_id="13" template="custom/featured-product.phtml" />
</reference>
</default>
, ben şöyle page/html/footer.phtml
açıkça bloğu çevirdim:
<?php echo $this->getChildHtml('product_of_the_month') ?>
bir fikir?
En iyi tahminle benim local.xml
yanlış olmasıdır. Yüklemem gereken bir ebeveyn bloğu var mı?
[Güncellemeler]
Benim orijinal kod ürün sayfası çöker. Geçici çözüm Magento çekirdek dosya üzerinde bu kadar ağır kod dayandırarak değil geçerli: catalog/product/list.phtml
.
<?php $_productCollection = $this->getLoadedProductCollection() ?>
[Çözüm]
CMS Sayfalar ve layoutXML kullanılmak üzere örneklerle bir çalışma versiyonunu buraya dahil edilmiştir: https://stackoverflow.com/a/12288000/1497746
'local.xml' - Bu dosyasının bulunduğu? (tam yol) – FlorinelChis
@FlorinelChis - Bu tema yedek hiyerarşisinde bir sorun değil. Özel bir paket için normal yer: /app/design/frontend/custom/custom/layout/local.xml –