magento variable for product detail view - magento

is there a variable to check if the product detail view (view.phtml) is used?
Why do I need this?
Price.phtml is used in product overview and product detail view also. I want to add a ifelse function when the price is shown on product detail view cause I want some more information.
Regards
Matt

Yup this is quite easy to achieve;
$pageIdentifier = Mage::app()->getFrontController()->getAction()->getFullActionName();
if($pageIdentifier == 'catalog_product_view') {
// Do something on product view page only
echo 'This is a product view page';
}

Related

magento - how to show only configurable product in main category, simple product in sub-category

I want to know how can I do this. I want to when i click main category, just show configurable product in page, and when i click sub-category, show simple product in page. Please help me in this, it will be really appreciated.
Thanks
You can check category level and then can display configurable product in it
if($category->getLevel() == 2){
$_productCollection1 = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('type_id','configurable');
foreach ($_productCollection1 as $product1) {
echo $product1->getName();
}
}
Hope this will help

How to create configuarable product programatically

I want to import configurable products in magento through xml. I have imported simple products.To create configurable product, I followed the process given here http://www.magentocommerce.com/boards/viewthread/46844/.
It works. If I remove
$data=array('5791'=>array('0'=>array('attribute_id'=>'491','label'=>'vhs','value_index'=>'5','is_percent'=>0,'pricing_value'=>'')),'5792'=>array('0'=> array('attribute_id'=>'491','label'=>'dvd','value_index'=>'6','is_percent'=>0,'pricing_value'=>'')));
$product->setConfigurableProductsData($data);
Still it works. and its good for me. But my problem is this code:
$data = array('0'=>array('id'=>NULL,'label'=>'Media Format','position'=> NULL,'values'=>array('0'=>array('value_index'=>852,'label'=>'vhs','is_percent'=>0,
'pricing_value'=>'0','attribute_id'=>'182'),'1'=>array('value_index'=>853,'label'=>'dvd',
'is_percent'=>0,'pricing_value'=>'0','attribute_id'=>'182')
),'attribute_id'=>182,'attribute_code'=>'media_format','frontend_label'=>'Media Format',
'html_id'=>'config_super_product__attribute_0'));
Can't i use just $product->getTypeInstance()->setUsedProductAttributeIds(array(491));
to set super-Attributeid =491 for configurable product ? Why the detail of attribute is required here?
Can anybody help me to find easiest way to create configurable product programmatically.
you have to see this link this is easiest way to create configurable product,
http://blog.omnisubsole.com/2009/07/01/configurable-products-in-magento/
goto app/design/frontend/default/your thme/template/catalog/product then open list.phtml
$product=Mage::getModel('catalog/product')->load($product_id);
$productType=$product->getTypeID();
//Simple Product
if($productType == 'simple')
{
//get simple product code here
}
//Configurable Product
if($productType == 'configurable')
{
//get Configurable Product code here
}

Directly go to Product Detail page on click the category?

In my store, one of the category has only one product. Is it possible to take the user directly to the product detail page of this one product whenever they click this category in the nav bar? i want to use some code to get this?
Put this in the product grid or list foreach loop in /app/design/frontend/default/[template]/template/catalog/product/list.phtml
<?php if ($_productCollection->count() == 1) {
$url = $_product->getProductUrl();
Mage::app()->getFrontController()->getResponse()->setRedirect($url); }
?>

To disable url for particular subcategory in magento cart

just got handed a magento site to update. No experience with the cart, so I hope these questions aren't too simplistic. Did search around a bit and haven't been able to find straightforward answers
=> For Some of my accessories showing in magento cart i does not want link on their title and image so how i made this dynamically.
Any help is appreciable
I have create a function in /app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php
public function getCustumcatId()
{
$proid=$this->getProduct()->getId();
$categoryIds=$this->getProduct()->getCategoryIds($proid);
foreach($categoryIds as $categoryId)
{
$category = Mage::getModel('catalog/category')->load($categoryId);
}
return $category->getName();
}
and call it on default.phtml of cart
after getting name i use if and else to remove link thanks for help and comment

Magento - Get category name in a custom product grid in homepage

I want to get the name of category in a custom category products grid in homepage
How can I do that ?
Thanks a lot
If you don't already have a variable containing a category object, create one:
$category = Mage::getModel('catalog/category')->load($categoryId);
Getting the name is then a simple matter of...
echo $category->getName();

Resources