简体   繁体   中英

Magento php core. Editing Product List Catalog

I've got a quick questions for magento experts. I would like to make changes on the PHP core of magento.

I want to add details on product listings, the details will depends on each product, and I want to display the extra details on the catalog list, so it involves the database & PHP.

So my questions is - where can do this? I am not familiar with the magento file structure and I need this rush, I hope I'll have time to study its structure but it will probably take more time than my deadline.

Take note that I am talking about the admin product list, not the customer carting.

You can probably do all of that logic in /template/catalog/product/view.phtml, if is the detail page. If its the category page it would be /template/catalog/product/list.phtml. Either way it would be the same.

$categories = $product->getCategoryIds();  //this is array of category ids the product exists in

$blueCategoryIds = array(1,2,3,4);  
$redCategoryIds = array(5,6,7,8);

if(in_array($blueCategoryIds,$categories)){
    $newClass = 'blue-background';
} elseif (in_array($redCategoryIds,$categories)) {
    $newClass = 'red-background';
} else {
    $newClass='';
}

Define .blue-background and .red-background in a CSS file.

.red-background {background:red;}
.blue-background {background:blue;}

Then use $newClass in what ever html element you want to apply your background to. This probably should be part of a custom module a method, but this should you going quick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM