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.
Related
I want to show an attribute to a particular category products as it is not useful for other category products. There are specific attributes define for each category products and all attributes are different for each category products.
So, I don't want to show all attributes in all products. I just want to show those attributes which is required for a particular category products. Is there any way to define attribute as per category wise products?
Here is an option:
Created a new attribute set based on default attribute set.
Assign your desired attribute into the new attribute set.
Select new created attribute set during the product add.
You can use this new created attribute set for your targeted categories.
You can write this code in your view.phtml file.
<?php
$product_id = $_product->getId();
$your_custom_product_id = array('51','52','53','54','55','56'); // Your customs Product Ids
if(in_array($product_id,$your_custom_product_id)) {
$attribute = $_product->getResource()->getAttribute(‘attribute_code’);
echo $attribute->getFrontendLabel();
echo $attributeValue = Mage::getModel(‘catalog/product’)->load($_product->getId())->getMyAttribute();
}
?>
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; ?>
Not finding anything on google that solves this problem.
I'm trying to add keywords attribute after the description of the product.
Tried:
<?php echo $_product->getMetaKeyword() ?>
<?php echo $_helper->productAttribute($_product, $_product->getMetaKeyword(), 'meta_keyword') ?>
< ?php echo $_product->getAttributeText('meta_keyword') ?>
I'm want add this on list.phtml
\app\design\frontend\default\mt_Bonasa\template\catalog\product\list.phtml
Go to the attribute managment and configure the
meta_keyword
attribute to be "used in product listing". Then it will be joined to the collection and you can simply fetch it via:
$_product->getMetaKeyword()
Here a screenshot how its set out of the box - switch to "yes"
I am trying to load a custom category in the catalog/category/view.phtml to archive this I use:
<?php
$_category = Mage::getModel('catalog/category')->load(47);
$_productCollection = $_category->getProductCollection();
if($_productCollection->count()) {
foreach( $_productCollection as $_product ):
echo $_product->getProductUrl();
echo $this->getPriceHtml($_product, true);
echo $this->htmlEscape($_product->getName());
endforeach;
}
?>
I can load the URL for example, now I want to load a custom attribute for example color:
$_product->getResource()->getAttribute('color')->getFrontend()->getValue($_product)
This code does not work, I am 100% sure the color attribute is set to show in the category listing and also that the items in this category have this fields fill. I know this because this code works on list.html.
What I am doing wrong? I am working with 1.7.0.2.
The expected result is to show all COLOR attibutes from a custom cateogory in
catalog/category/view.phtml
I can't believe I just found the answer. Because we are not in a regular category listing we need to add the custom attributes to the collection.
Here is the code:
$_productCollection = $_category->getProductCollection()
->addAttributeToSelect('color');
If "color" is in the flat table you should be able to
$_product->getColor();
If this attribute is not in the collection, you can either add it to the flat table by making the attribute filterable, add it in the PHP collection call
$_productCollection = $_category->getProductCollection()
->addAttributeToSelect('color');
Or load the product model to get all of the attributes
$_product = Mage::getModel('catalog/product')->load($_product->getId());
echo $_product->getColor();
Make this attribute visible in listing/frontend
Run Reindexing
foreach( $_productCollection as $_product ):
echo $_product->getProductUrl();
in this code var_dump $_product->getData(); check if this var_dump results in that specific attribute value getting displayed.
Note:
$_product->getResource()->getAttribute('color')->getFrontend()->getValue($_product)
is not a very efficient way of calling.
I have a Magento site.
I have a number of products to add.
But some have price as "Contact for Pricing" or "Call for Pricing" so cant to add.
Because there has validation for the price.
So how can I add such products?
If there is any module for such products?
I need to display such product's price as "Contact for Pricing" or "Call for Pricing".
if there is an extension for "call for price" download free?
Josh's answer slightly improved. Thanks Josh for the Idea of using attributes!
Create the attribute code 'call_4_price' for this example. Like Josh suggested, make it a Yes/No attribute. Default Value "No". Add it to attribute sets where you'll need to hide prices.
Find all .phtml files where "prices & add to cart buttons" are (template > catalog > product > view.phtml, price.phtml, list.phtml, etc)
Paste this code Before the price code.
<!-- Call For Price - begin -->
<?php $attribute = $_product->getResource()->getAttribute('call_4_price'); ?>
<?php $attribute_value = $attribute ->getFrontend()->getValue($_product); ?>
<?php if ($attribute_value == 'Yes'): ?>
//Please Call for pricing
<?php else: ?>
And this after the add to cart button.
<?php endif; ?>
<!-- Call For Price - end -->
Create an Yes/No attribute for Call For Price. When creating products, put something into the price field just to get past validation.
Now modify your template files to not show the price if it Call For Price is set to 'Yes'.