I want to create custom category attributes dynamically(through Form) in admin.
I mean, how can I create custom category attributes through Model/Controller class?
Please suggest me proper solution to resolve this issue.
Thanks in advance!
Maybe this free extension will help you.
I Use it on Magento 1.9
Case: At backend I Created an attribute with Attributecode : category_custom_attribute
To display on category : edit /app/design/frontend/your-template/your-template/template/catalog/category/view.phtml
<?php $category = Mage::registry('current_category'); ?>
<?php $CatCustomAttribute = $category->getCategory_custom_attribute(); ?>
<?php echo $CatCustomAttribute; ?>
Related
I want to extract the Brand and other attributes within the "Specification" under "Product Information" (Catalog -> Manage Products - then select a product).
I can get the product name by doing the following:
<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>
I need something similar to display a Specification attribute on the front end.
How do I do this?
Thank you
This worked for me :
$_product = $this->getProduct();
$guarantee = Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'spec_guarantee', 1); // 1 is the store id
echo $guarantee;
// outputs:
// 2 Years Manufacturers Guarantee
In magento 1.9 I used the following code to display a custom attribute.
<?php $_product->getData('takealotlink'); ?>
However to make sure it displays in the front-end you also have to set the correct property from manage attributes.
The property to set in Front-end properties is "Used in product listing". See arrow below.
I would like to add meta tags in my product page like
> , : my company name
currently I am using meta descriptions in my magento admin.
Thanks in Advance
you can go to View.phtml from Product module, and there you put something like that
<?php echo '<'.Mage::getStoreConfig('company_name').'>' ?>
<?php echo '<'.Mage::getStoreConfig('other').'>' ?>
I have a question about Mage::registry and categories: I'm a on a category page, I retrieve current category by Mage::registry('current_category'). I've noticed that it works only for root categories, in fact if I visit a subcategory page I retrieve always the root category with Mage::registry('current_category'). So the question is: is something about backend configuration, cache or something else?
If you are in a template (e.g. catalog/category/view.phtml) you can get the current category with
$this->getCurrentCategory();
If you are in a model, controller or else, try this (found here):
Mage::getModel('catalog/layer')->getCurrentCategory();
However, Mage::registry('current_category') is the normal way to go.
OOB, current_category is set in Mage_Catalog CategoryController::_initCategory() (ref here) and will always be equal to the category currently being viewed.
If your data is different then your app has non-standard functionality or you are seeing cached results.
For all categories:-
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
For Current Category
<?php $currentCategory = Mage::registry('current_category') ?>
Works for me.
How do I include the SKU as well as the product name in the page title (when looking at the product details page)?
Cheers!
In app/design/frontend/default/{your theme Folder}/template/page/html/head.phtml you could try
<?php if ($_product = Mage::registry('current_product')) { ?>
<title><?php echo $_product->getName() . ' ' . $_product->getSku(); ?></title>
<?php }else{ ?>
<title><?php echo $this->getTitle() ?></title>
<?php } ?>
You could also do this using an observer for catalog_controller_product_view see Magento Change Product Page Titles to Include Attributes
If you have a collection already loaded (ie. on product view page)
$_product->getSku();
If for some reason you need to call this from a different template higher up in the chain that isn't already loading the product/collection, you can drop this one:
$_product = Mage::registry('current_product');
$_product->getSku();
look at your design template in catalog/product/view.phtml file you should be able to simply do $_product->getData('sku');
On the default product view page for magento where is "getPriceHtml" function located or what is being called here:
<?php echo $this->getPriceHtml($_product) ?>
Several words are being displayed by this code such as "Price From:" with the price included afterwards. This is for a configurable product.
Mage_Catalog_Block_Product::getPriceHtml()
This method renders via app/design/frontend/base/default/template/catalog/product/price.phtml
a.k.a The Worst Template In Magento®
benmark's answer comes down to this:
<?php echo Mage_Catalog_Block_Product::getPriceHtml($_product, true) ?>
Where $_product relates to the product object.
$productBlock = new Mage_Catalog_Block_Product();
$priceBlock = $productBlock->getPriceHtml($_product, true);
echo $priceBlock;