The products that are passed by the collection to the list view only contain the basic attributes, description and price are not included.
The easiest thing to is to instantiate the product model and pull the attributes you need with ->getData('attribute').
example:
$product_attr = Mage::getModel('catalog/product')->load($_product->getId());
then you will get your attributes by replacing:
<?php echo $_product->getDescription(); ?>
<?php echo $_product->getPrice(); ?>
with :
<?php echo $product_attr->getData('description'); ?>
<?php echo $product_attr->get('price'); ?>
Although, the recommended way to do it, is to add an observer to the 'catalog_block_product_list_collection' event and add those attributes to the collection
Did you check that the information exist on the DOM, if it is then you probably need to change the query, when you are using an ID (#) selector on jQuery it will only grab the first element that it finds that matches that query you can add specificity to the query by adding an scope the element that you want to show.
try changing the your selector to affect an element that falls within the scope of the element that is triggering the event
something simple like:
jQuery('.product-image')
.mouseover(function () {
jQuery('#hidden_image', $(this)).show();
})
.mouseout(function () {
jQuery('#hidden_image', $(this)).hide();
})
Add below code in your file
app/design/frontend/yourtheme/yourpackage/catalog/product/new.phtml
<?php
/**
* Product list template
*
* @see Mage_Catalog_Block_Product_List
*/
/* @var $this Mage_Catalog_Block_Product_List */
?>
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<?php // Product Image ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
<?php /* Based on the native RWD styling, product images are displayed at a max of ~400px wide when viewed on a
one column page layout with four product columns from a 1280px viewport. For bandwidth reasons,
we are going to serve a 300px image, as it will look fine at 400px and most of the times, the image
will be displayed at a smaller size (eg, if two column are being used or viewport is smaller than 1280px).
This $_imgSize value could even be decreased further, based on the page layout
(one column, two column, three column) and number of product columns. */ ?>
<?php $_imgSize = 300; ?>
<img id="product-collection-image-<?php echo $_product->getId(); ?>"
src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(false)->resize($_imgSize); ?>"
alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>
<?php // Product description ?>
<div class="product-shop">
<div class="f-fix">
<div class="product-primary">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
</div>
<div class="desc std">
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
</div>
</div>
</div>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php else: ?>
<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col">
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php /*if ($i++%$_columnCount==0): ?>
<?php endif*/ ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
<?php $_imgSize = 210; ?>
<img id="product-collection-image-<?php echo $_product->getId(); ?>"
src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>"
alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>
<div class="product-info">
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
</div>
<div class="desc std">
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
</div>
</li>
<?php /*if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
<?php endif*/ ?>
<?php endforeach ?>
</ul>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
<?php endif; ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
</div>
<?php endif; ?>
<?php
// Provides a block where additional page components may be attached, primarily good for in-page JavaScript
if ($this->getChild('after')) {
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach ($_afterChildren as $_afterChildName) {
$_afterChild = $this->getChild('after')->getChild($_afterChildName);
//set product collection on after blocks
$_afterChild->setProductCollection($_productCollection);
echo $_afterChild->toHtml();
}
}
?>
Add below code to when you want to ad in cms block or cms page:
{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}}
Best Answer
You could try setting a default value for the
short_description
attribute, from the admin panel go to Catalog > Attributes > Manage Attributes. However, you would need to remove all the values set for the existing products. I would do this with a tool called magmi mass importer.Perhaps a better approach would be to remove the short description from the product view page and create a static block with your content and add this to the product view page.
For this method you first need to create a static block with your content, next add it to your layout xml, you need to find out the layout handle for your product view page, probably either
PRODUCT_TYPE_configurable
orPRODUCT_TYPE_simple
or both? Then use theunset_child action
method to remove the short description or you may need to just comment it out from your theme'scatalog/product/view.phtml
template file if it is not added by layout xml. Then make your recently created static block available to your product page with something like.Finally to add your static block to your product pages use the below code snippet in your phtml template file, next to where the short description was being called.
I think the second method is best as your content is not a short description of the product but rather useful information about your store and as such this data should not be held in the 'short_description' attribute which may be used elsewhere in the system, I.e. shopping cart, transactional emails etc.
Good luck