Tuesday, March 16, 2010

Jut for fun!

While working on a theme for Magento 1.4.0.1 I found this in app\design\frontend\base\default\template\checkout\onepage\shipping.phtml between lines 49 and 56
<?php if(false): ?>
<div class="fields">
<label for="shipping:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
<div class="input-box">
<input type="text" name="shipping[email]" id="shipping:email" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
</div>
</div>
<?php endif ?>

Good one Magento Team.

Monday, March 1, 2010

Retrieve attributes by groupId

Problem: how to retrieve product attributes by group id.
See here: http://www.magentocommerce.com/boards/viewthread/79694/

Possible solution:
<?php
require_once 'path/to/app_dir/app/Mage.php';
Mage::app('default');
$product = Mage::getModel('catalog/product');
$product->setAttributeSetId('THE ATTRIBUTE SET YOU WANT TO USE');
$groupId = 'THE ID OF THE GROUP YOU WANT TO RETRIEVE';

$collection = $product->getAttributes($groupId, false);
foreach($collection as $attribute){
//do something with the attribute
}
?>