Magento – View products without product image / Hide

Picture

New products have arrived and are set directly in the Magento Store. The setting of the photos but unfortunately takes a little. Well this article should not be displayed by default on the product pages until they have a picture.
Of course, there is the possibility to adjust the product itself, that it is not visible or it is disabled, etc..

But it is also simple and direct.

The file responsible for product selection (e.g.. New.php im Ordner app/code/local/Mage/Catalog/Block/Product)

complete the following:

$collection ->addAttributeToFilter('small_image',array('Musical' =>'','neq'=>'no_selection'));

but it may also in an existing collection only $

->addAttributeToFilter('small_image',array('Musical' =>'','neq'=>'no_selection'))

be added (be careful, the last filter a ; behind the ) has)

The o.g. Version was necessary, because the triage was not carried out via a script PHTML, but by the PHP file.

To be carried out a general selection, that no items are listed without a picture in each category, the line can

->addAttributeToFilter('small_image',array('Musical' =>'','neq'=>'no_selection'))

list.phtml in the folder app / design / frontend /[base or default]/[IhrTemplate]/template/catalog/category ca. in line 126 to

$_productCollection->addCategoryFilter($category)
    ->setPageSize($length)
    ->setCurPage($currentPage)
    ->addAttributeToSelect('*');

e.g. so that after. looks:

    $_productCollection->addCategoryFilter($category)
    ->setPageSize($length)
    ->setCurPage($currentPage)
    ->addAttributeToFilter('small_image',array('Musical' =>'','neq'=>'no_selection'))
    ->addAttributeToSelect('*');

Thus all the items will not be displayed, have not deposited the item image. Once the image, but then there, the article will also appear.

Picture

Another useful filters struck me just below the eye: Show only articles, which are also visible (Visibility: Individually not visible, Catalog, Search, Catalog Search). Actually, this should be yes of course. But I just had a template which was not taken thereon. So I wanted to make sure, that only items are displayed, the “Catalog Search” had a characteristic. For this I have pasted below the top line still

->addAttributeToFilter('visibility' , Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)

inserted. It could also be e.g..

->addAttributeToFilter('visibility' , Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG)

for products, which are visible in the catalog or

->addAttributeToFilter('visibility' , Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)

for products, which are not individually visible.

Used in Magento Version 1.5.1.0 Comments? Additions? Notes? Gladly!

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

Leave a Reply

Your email address will not be published. Required fields are marked *