Magento new products are not showing in homepage - magento

In magento I want to show new products in my home page. So to do that I have searched many blogs and forums. From all of them I have got that by using
{{block type="catalog/product_new" block_id="new.products" template="catalog/product/new.phtml"}}
in CMS -> Homepage content I will get the new products. But still I am not getting any products. Also I have tried to change the date active . But it is not showing any products. So can someone kindly tell me what is the issue here? Any help and suggestions will be really appreciable. Thanks

In default Magento implementation of catalog/product_new block the rules are:
the product should be visible in catalog
the product should have both news_from_date and news_to_date attributes set to some values
attribute news_from_date works till end of today's date (23:59:59) and attribute news_to_date works from the begin of today's date (00:00:00)
When there be at least one product that meet that requirements the block will be rendered. Also flushing your cache and reindexing data could help as well.

Just in case you end up here, there is another simple fix to try:
System -> Index Management
and select them all (even if they are indicating "Green, no re-index needed" and force them to reindex.
This solved my empty getSize() problem, which in turn, allowed the Special and New database requests to find the products, fulfill the "if" conditions and properly render.

try this
write following code in cms->page->design tab->Layout Update XML
<reference name="content">
<block type="catalog/product_list" name="featured" template="catalog/product/new.phtml">
</block>
</reference>
you have to add new.phtml file in "app\design\frontend\default\default\template\catalog\product"
write following code in new.phtml file
<?php
/******************
//Recently Added Products
************************/
$_helper = $this->helper('catalog/output');
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setVisibility(array(2,3,4))
->setOrder('created_at', 'desc');
?>
<div style="clear: both;"></div>
<div id="block">
<div class="text">Recently Added Products
View more »
</div>
</div>
<?php foreach($_productCollection as $_product) : ?>
<div class="grid">
<div class="imgholder" >
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>"
class="product-image">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135"
alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
</div>
<strong><?php echo $_product->getName(); ?></strong>
<p><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></p>
<div class="price">
<?php echo $this->getPriceHtml($_product, true) ?>
</div>
</div>
<?php endforeach; ?>

You can also display it using Widget. I mean by adding widget in CMS homepage.

I had this probalem and spoke to an agent who took control of it for me and worked it out as explaining it didnt help. You need to put all the nav categories into the highest root category (so all categories will look like subcategories of the first root which you cannot delete. They must not be or be stemming from any paralell root categories. Then refresh your index and the category items will be there in the nav menu.

Related

Magento Static block now showing up in CMS Page

Hy ! I'm trying to display the categories on a cms page.I've tried all the solution on the web but none is working for me. The last one i've tried is this.
1.I've added this code in content tab of my cms page :
{{block type="catalog/navigation" template="catalog/category/list.phtml"}}
2.I've created the list.phtml and put the file on app/design/theme-name/template/catalog/category.
Here is the code pf my file
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $open = $this->isCategoryActive($_category); ?>
<?php
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
if ($immagine = $this->getCurrentCategory()->getImageUrl()):
?>
<div class="catalog-image">
<div>
<a href="<?php echo $this->getCategoryUrl($_category)?>">
<img src="<?php echo $immagine ?>" alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" width="313" height="151" />
</a>
</div>
<div class="left"><h2><?php echo $_category->getName()?></h2></div>
</div>
<?php endif; ?>
<?php endforeach; ?>
What I'm doing wrong ? Thanks !
Add this code in content tab of your cms page:
{{block type="core/template" template="page/categories-list.phtml"}}
Create a file in the theme such "categories-list.phtml"
path: app/design/theme-name/template/page/categories-list.phtml
In this file, write the following code in order to get a collection of all the categories:
<?php
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter();
?>
If you want only some categories of parent, use the following code:
<?php
$parent_category_id = 5; // this is ID of parent category
$categories = Mage::getModel('catalog/category')->getCategories($parent_category_id);
?>
To display categories on the screen, use loop, look below:
<?php foreach ($categories as $category): ?>
<p><?php echo $category->getImageUrl(); ?></p>
<p><?php echo $category->getName(); ?></p>
<?php endforeach; ?>
If you use the categories of the parent category to display the image, use the following code:
Mage::getModel('catalog/category')->load($category->getId())->getImageUrl();
Create a folder under catalog with name navigation and put your list.phtml file there it will work.
{{block type="core/template" template="catalog/navigation/list.phtml" category_id="507" }}
Category Display Mode shuould be in static block in display setting.

Display a specific subcategory product using PHTML

what should be the code in phtml file to show one specific subcategory product on home page ?
I have created a file in catalog/product/topSection.phtml with following code-
<?php
$cat_id = 42;
$category = Mage::getModel('catalog/category')->load($cat_id);
$products = $category->getProductCollection();
echo 'total- '.$products->count();
foreach($products as $product){ ?>
<h3>
<img src="<?php echo $product->getImageUrl() ?>" alt="">
<p><?php echo $product->getName() ?></p>
</h3>
<?php }?>
and used
{{block type="core/template" name="top.section.home" template="catalog/product/topSection.phtml"}}
in home page content. but nothing is displaying. what is wrong in my code.
I checked your code it is working and also display product. First please check category id and sure category is enable ?

add description grid list on theme mobile shoppe

i try to add "short description" on my category list of my products but nothing happend on my list.phtml
i try on: app/design/frontend/base/default/template/catalog/product/list.phtml
in my lit view are there this code:
(and i copy this code to grid block but nothing happend)
<div class="desc std">
<h1>test</h1>
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<?php echo $this->__('Learn More') ?>
</div>
Go to Catalog->Attributes->Manage attributes, search for the short_description attribute, edit it and set the field Used in product listing to Yes. Reindex everything and it should work.
[EDIT]
Or you can simply use this:
<?php echo $_product->getShortDescription();?>

How do I get the rating summary in new products section on my homepage?

On my homepage I have “New products” section. I created it with the following code:
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage2" template="catalog/product/new.phtml">
<action method="setColumnCount"><columns>3</columns></action>
<action method="setProductsCount"><count>3</count></action>
</block>
That works fine, but I want also show the rating summary (stars and amount of reviews) om my homepage:
<?php if($_product->getRatingSummary()): ?>
<div class="ratingsum">
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
</div>
The code above gives nothing back. It seems that there are no reviews, but I definitely know that there are reviews!
The problem seems the block type, for new products: catalog/product_new and for bestsellers bestsellers/list, is that possible?
I have also a “best sellers” section on my homepage. There is getting the rating summary no problem.
Also:
$_productCollection=$this->getLoadedProductCollection();
Doesn't work in my new.phtml. It returns no collection/products.
Below is the code to retrieve product rating summary.
$storeId = Mage::app()->getStore()->getId();
$summaryData = Mage::getModel('review/review_summary')
->setStoreId($storeId)
->load('product_id');
if($summaryData->getRatingSummary()){
?>
<div class="rating-box" style="float:left;">
<div class="rating" style="width: <?php echo $summaryData->getRatingSummary().'%'; ?>"></div>
</div>
<?php
}
Just be sure to pass it the right product id number.

Magento categories listing using getCollection & addLevelFilter but exclude Default Root Category

I'm using the following code to grab a collection and to filter on a level using addLevelFilter(2). This outputs all my categories at level 2 perfectly except it also pulls through the Default Root Category in my list. I want to exclude this from view but having looked through all the available methods, I see nothing that will help me remove/exclude certain levels or categories. I really want a full proof solution so if I were to choose say level 3 it would only show level three and not level 1,2,3. Does anyone have a suggestion to pull only a certain level/categories!!??
<?php
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter()
->addLevelFilter(2)
->addOrderField('name');
foreach($categories as $category):
?>
<div class="home-cats">
<div class="product-image">
<a href="<?php echo $category->getURL() ?>" title="<?php echo $this->htmlEscape($category->getName()) ?>">
<img src="<?php echo $category->getImageUrl() ?>" width="88" alt="<?php echo $this->htmlEscape($category->getName()) ?>" />
</a>
</div>
</div>
<?php endforeach; ?>
Any advice/feedback would be greatly appreciated. Cheers, Sahus
you can try
->addAttributeToFilter('level',2)
this may work for you

Resources