Remove Custom Option "None" - magento

I'm new to Magento. We've created a custom option. But whenever we choose "radial" it always displays a "None" option that we need to remove. I from what I understand this is pulling in some code from Magento Core.
This is the HTML that I need to edit:
<dt><label>Add a Display Case:</label></dt>
<dd class="last">
<div class="input-box">
<ul id="options-7-list" class="options-list"><li><input type="radio" id="options_7" class="radio product-custom-option" name="options[7]" onclick="opConfig.reloadPrice()" value="" checked="checked" /><span class="label"><label for="options_7">None</label></span></li><li><input type="radio" class="radio product-custom-option" onclick="opConfig.reloadPrice()" name="options[7]" id="options_7_2" value="19" price="45" /><span class="label"><label for="options_7_2">Acrylic Cube <span class="price-notice">+<span class="price">$45.00</span></span></label></span></li><li><input type="radio" class="radio product-custom-option" onclick="opConfig.reloadPrice()" name="options[7]" id="options_7_3" value="20" price="75" /><span class="label"><label for="options_7_3">Lucite Case <span class="price-notice">+<span class="price">$75.00</span></span></label></span></li></ul> </div>
</dd>
This is where I think it outputs....
<?php
class OptionExtended_Block_Product_View_Js extends Mage_Catalog_Block_Product_View_Options
{
protected $config = array();
protected $thumbnailDirUrl = '';
protected $pickerImageDirUrl = '';
protected function _construct()
{
$children = array();
$sd = array();
$configValues = array();
$inPreConfigured = $this->getProduct()->hasPreconfiguredValues();
$storeId = Mage::app()->getStore()->getId();
$product_id = $this->getProduct()->getId();
$filter = Mage::getModel('core/email_template_filter');
$options = $this->getProduct()->getOptions();
foreach ($options as $option){
if (!is_null($option->getLayout())){
$id = (int) $option->getOptionId();
if (!is_null($option->getRowId()))
$option_id_by_row_id[$option->getTemplateId()][(int) $option->getRowId()] = $id;
$this->config[0][$id][0] = $option->getNote() != '' ? $filter->filter($option->getNote()) : '';
$this->config[0][$id][1] = $option->getLayout();
$this->config[0][$id][2] = (int) $option->getPopup();
if ($inPreConfigured){
$configValues[$id] = array();
if (is_null($option->getRowId())){
$configValue = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $id);
if (!is_null($configValue))
$configValues[$id] = (array) $configValue;
}
} else {
$sd[$option->getTemplateId()][$id] = explode(',', $option->getSelectedByDefault());
}
if (!is_null($option->getValues())){
foreach ($option->getValues() as $value) {
$valueId = (int) $value->getOptionTypeId();
$this->prepareImages($value->getImage());
$rowId = (int) $value->getRowId();
$valueId_by_row_id[$value->getTemplateId()][$rowId] = $valueId;
$children[$value->getTemplateId()][$valueId] = explode(',', $value->getChildren());
$this->config[1][$valueId][0] = $value->getImage();
$this->config[1][$valueId][1] = $value->getDescription() != '' ? $filter->filter($value->getDescription()) : '';
$this->config[1][$valueId][2] = array();
$this->config[1][$valueId][3] = array();
}
}
}
}
$options = Mage::getModel('optionextended/option')
->getCollection()
->joinNotes($storeId)
->addFieldToFilter('product_id', $product_id);
foreach ($options as $option){
$id = (int) $option->getOptionId();
if (!is_null($option->getRowId()))
$option_id_by_row_id['orig'][(int) $option->getRowId()] = $id;
$this->config[0][$id][0] = $option->getNote() != '' ? $filter->filter($option->getNote()) : '';
$this->config[0][$id][1] = $option->getLayout();
$this->config[0][$id][2] = (int) $option->getPopup();
if ($inPreConfigured){
$configValues[$id] = array();
if (is_null($option->getRowId())){
$configValue = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $id);
if (!is_null($configValue))
$configValues[$id] = (array) $configValue;
}
} else {
$sd['orig'][$id] = explode(',', $option->getSelectedByDefault());
}
}
$values = Mage::getModel('optionextended/value')
->getCollection()
->joinDescriptions($storeId)
->addFieldToFilter('product_id', $product_id);
foreach ($values as $value) {
$valueId = (int) $value->getOptionTypeId();
$this->prepareImages($value->getImage());
$rowId = (int) $value->getRowId();
$valueId_by_row_id['orig'][$rowId] = $valueId;
$children['orig'][$valueId] = explode(',', $value->getChildren());
$this->config[1][$valueId][0] = $value->getImage();
$this->config[1][$valueId][1] = $value->getDescription() != '' ? $filter->filter($value->getDescription()) : '';
$this->config[1][$valueId][2] = array();
$this->config[1][$valueId][3] = array();
}
if ($inPreConfigured){
foreach ($configValues as $optionId => $v){
$this->config[0][$optionId][3] = array();
foreach($v as $valueId)
$this->config[0][$optionId][3][] = (int) $valueId;
}
} else {
foreach ($sd as $templateId => $v){
foreach ($v as $optionId => $vv){
$this->config[0][$optionId][3] = array();
foreach($vv as $rowId)
if ($rowId != '')
$this->config[0][$optionId][3][] = $valueId_by_row_id[$templateId][(int)$rowId];
}
}
}
foreach ($children as $templateId => $v){
foreach ($v as $valueId => $vv){
foreach ($vv as $rowId){
if ($rowId != ''){
if (isset($option_id_by_row_id[$templateId][(int)$rowId]))
$this->config[1][$valueId][2][] = $option_id_by_row_id[$templateId][(int)$rowId];
else
$this->config[1][$valueId][3][] = $valueId_by_row_id[$templateId][(int)$rowId];
}
}
}
}
}
public function getConfig()
{
return Zend_Json::encode($this->config);
}
public function prepareImages($image)
{
if ($image){
$thumbnailUrl = $this->makeThumbnail($image);
$pickerImageUrl = $this->makePickerImage($image);
if ($this->thumbnailDirUrl == ''){
$this->thumbnailDirUrl = str_replace($image, '', $thumbnailUrl);
$this->pickerImageDirUrl = str_replace($image, '', $pickerImageUrl);
}
}
}
public function makeThumbnail($image)
{
$thumbnailUrl = $this->helper('catalog/image')
->init($this->getProduct(), 'thumbnail', $image)
->keepFrame(true)
// Uncomment the following line to set Thumbnail RGB Background Color:
// ->backgroundColor(array(246,246,246))
// Set Thumbnail Size:
->resize(100,100)
->__toString();
return $thumbnailUrl;
}
public function makePickerImage($image)
{
$pickerImageUrl = $this->helper('catalog/image')
->init($this->getProduct(), 'thumbnail', $image)
->keepFrame(false)
->resize(30,30)
->__toString();
return $pickerImageUrl;
}
public function getThumbnailDirUrl()
{
return $this->thumbnailDirUrl;
}
public function getPickerImageDirUrl()
{
return $this->pickerImageDirUrl;
}
public function getPlaceholderUrl()
{
return Mage::getDesign()->getSkinUrl($this->helper('catalog/image')->init($this->getProduct(), 'small_image')->getPlaceholder());
}
public function getProductBaseMediaUrl()
{
return Mage::getSingleton('catalog/product_media_config')->getBaseMediaUrl();
}
public function getInPreconfigured()
{
return $this->getProduct()->hasPreconfiguredValues() ? 'true' : 'false';
}
}

I think you are doing something wrong.
From this picture you can see that you can add your options which are then displayed in the frontend. Only these options will be displayed!
You do not need to make any changes in the Magento Core code to fix your problem.
If you still have problems please provide us with some screenshots and URL to your Magento web shop if possible.

Are you using an extension such as SWMS Option Image or similar to add extras like images to your custom options? This extension adds the None option.
You will need to go into the community folder and select your extension and edit the default.php and change "None" to "Standard" or something similar.
For SWMS Option image I changed:
/community/Swms/Optionimage/Block/Product/View/Options/Type/Select.php
<label for="options_'.$_option->getId().'">' . $this->__('Standard') . '</label>

I've got another solution. Edit the csv file. Mage_Catalog.csv. Add a row for None and add the word Standard to the next column.

Issue was resolved by modifying the this file:
app/code/local/Mage/Catalog/Block/Product/View/Options/Type/Select.php
modified lines 102-106
<?php
switch ($_option->getType()) {
case Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO:
$type = 'radio';
$class = 'radio';
if (!$_option->getIsRequire()) {
// $selectHtml .= '<li><input type="radio" id="options_'.$_option->getId().'" class="'.$class.' product-custom-option" name="options['.$_option->getId().']"' . ($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') . ' value="" checked="checked" /><span class="label"><label for="options_'.$_option->getId().'">' . $this->__('None') . '</label></span></li>';
}
break;
case Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX:
$type = 'checkbox';
$class = 'checkbox';
$arraySign = '[]';
break;
}
?>

I have the same issue, also what i have found if the field is not required magento will generate "None" option. Fast solution but not recommended is hide the option by css.

Related

uploading multiple image in codeigniter using same input

views
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="userfile[]" size="40" multiple/>
<input type="submit" name="submit" value="Upload">
</form>
controller
public function image()
{
$data['error'] = '';
$this->load->model('StackM');
if(isset($_POST['submit']))
{
$data['update_pass_error_msg'] = $this->StackM->add_multiple_image();
}
$this->load->view('stack_view');
}
Model
public function add_multiple_image(){
if((!empty($_FILES['f2']['name'])))
{
$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$files = $_FILES;
if ($files['f2']['name'][0] == '' )
{
# code...
return "Select a file to upload";
}
else
{
$mum_files = count($files['f2']);
for($i=0; $i<$mum_files; $i++)
{
if ( isset($files['f2']['name'][$i]) )
{
$config['file_name'] = time().'-'.$files['f2']['name'][$i];
$this->load->library('upload', $config);
$_FILES['f2']['name']= $files['f2']['name']["$i"];
$_FILES['f2']['type']= $files['f2']['type']["$i"];
$_FILES['f2']['tmp_name']= $files['f2']['tmp_name']["$i"];
$_FILES['f2']['error']= $files['f2']['error']["$i"];
$_FILES['f2']['size']= $files['f2']['size']["$i"];
$filename = rand().'-'.$_FILES['f2']['name'];
if (!empty($this->upload->do_upload('f2')))
{
$dataInfo[] = $this->upload->data();
$all_imgs = '';
if ( count($dataInfo) > 0) {
# code...
foreach ($dataInfo as $info) {
# code...
$all_imgs .= $info['file_name'];
$all_imgs .= ',';
}
}
}
}
}
}
}
else{
$all_imgs = "";
}
}
}
else{
$all_imgs = $this->session->userdata('image');
}
$this->db->insert('table_name', $all_imgs);
The problem I am facing in this code is Think suppose if I am adding 7 images, but it's showing only 5 images in database it's not taking more then five and also I want to know while editing the form if I don't want to change the image then it should remain same image so i have stored the old image in session and checking if it is empty then only it should session variable .
But In my code if I will not upload new one If I keep old image as then it will save blank
To avoid the offset error, inside of for loop you need to check if that array index is set or not:
Here I have a demo code to upload multiple files in CodeIgniter:
views/stack_view.php
<?php if ($this->session->flashdata('status')) { ?>
<h5><?=$this->session->flashdata('status')?>: <?=$this->session->flashdata('message')?></h5>
<?php } ?>
<?=form_open_multipart('stack', array('id' => 'my_id'))?>
<input type="file" name="userfile[]" size="40" multiple/>
<input type="submit" name="submit" value="Upload">
<?=form_close()?>
controllers/Stack.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Stack extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->helper(array('form', 'url'));
}
public function index()
{
if ($this->input->post('submit')) {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$files = $_FILES;
if ($files['userfile']['name'][0] == '' ) {
# code...
$this->session->set_flashdata('status', 'error');
$this->session->set_flashdata('message', "Select a file to upload");
}
else
{
$mum_files = count($files['userfile']);
$dataInfo = array();
for($i=0; $i<$mum_files; $i++)
{
if ( isset($files['userfile']['name'][$i]) ) {
$config['file_name'] = time().'-'.$files['userfile']['name'][$i];
$this->load->library('upload', $config);
$_FILES['userfile']['name']= $files['userfile']['name']["$i"];
$_FILES['userfile']['type']= $files['userfile']['type']["$i"];
$_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name']["$i"];
$_FILES['userfile']['error']= $files['userfile']['error']["$i"];
$_FILES['userfile']['size']= $files['userfile']['size']["$i"];
$filename = rand().'-'.$_FILES['userfile']['name'];
if ( ! $this->upload->do_upload('userfile'))
{
$error_message = $this->upload->display_errors();
$this->session->set_flashdata('status', 'error');
$this->session->set_flashdata('message', "$error_message");
}
else
{
//$data = array('upload_data' => $this->upload->data());
$this->session->set_flashdata('status', 'success');
$this->session->set_flashdata('message', "Files upload is success");
}
$dataInfo[] = $this->upload->data(); //all the info about the uploaded files are stored in this array
}
}
//here you can insert all the info about uploaded file into database using $dataInfo
$all_imgs = '';
if ( count($dataInfo) > 0) {
# code...
foreach ($dataInfo as $info) {
# code...
$all_imgs .= $info['file_name'];
$all_imgs .= ',';
}
}
$insert_data = array(
'your_column_name' => rtrim($all_imgs,",")
);
$this->db->insert('your_table_name', $insert_data);
}
}
$this->load->view('stack_view');
}
}
Try this script and I hope you will get some help from this.
This is working script try to upload it
public function upload()
{
$this->load->library('session');
if ( ! empty($_FILES))
{
$config['upload_path'] = "assets/uploads/";
$config['allowed_types'] = 'jpg|png|jpeg';
$config['max_size'] = 5120; //limit only 5 Mb
$this->load->library('upload');
$files = $_FILES;;
$number_of_files = count($_FILES['files']['name']);
$errors = 0;
$myname = $this->input->post('ad_title');
for ($i = 0; $i < $number_of_files; $i++)
{
//$randVal = rand(450,4550).time('d-y-m');
$filename = basename($files['files']['name'][$i]);
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$new = md5($filename.''.time('d-y-m')).'.'.$extension;
$_FILES['files']['name'] = $new; //$files['files']['name'][$i];
$_FILES['files']['type'] = $files['files']['type'][$i];
$_FILES['files']['tmp_name'] = $files['files']['tmp_name'][$i];
$_FILES['files']['error'] = $files['files']['error'][$i];
$_FILES['files']['size'] = $files['files']['size'][$i];
$image = array('upload_data' => $this->upload->data());
$image_name = $_FILES['files']['name'];
$ip = $this->input->ip_address();
$this->session->set_userdata("userIP",$ip);
//$this->session->unset_userdata("userIP");
$Dval = array(
"filename" => $image_name,
"ip" => $this->input->ip_address()
);
$this->member_model->tmp_image($Dval);
$this->upload->initialize($config);
if ( $this->upload->do_upload("files"))
{
$errors++;
$data = $this->upload->data();
echo json_encode($data['file_name']);
//code is for thumbnail and watermark on images
//$this->watermark($data['full_path']);
//$myPathfT = $config1['upload_path'] = "./assets/thumbs/".$aDir;
//mkdir($myPathfT);b
$config1 = array();
$config1['image_library'] = 'gd2';
$config1['source_image'] = $data['full_path'];
$config1['new_image'] = 'assets/uploads/thumbs/';
$config1['create_thumb'] = false;
$config1['quality'] = 50;
$config1['height'] = 150;
$config1['width'] = 150;
$this->load->library('image_lib',$config1);
$this->image_lib->initialize($config1);
$this->image_lib->resize();
$this->image_lib->clear();
}
}
if ($errors > 0)
{
//echo "Data Transferred";
}
}
elseif ($this->input->post('file_to_remove'))
{
$aDir = $this->session->userdata('Dir');
$file_to_remove = $this->input->post('file_to_remove');
unlink("./assets/mainFilesData/$aDir/" . $file_to_remove);
$array = $this->session->userdata('photo');
$dataF = array_diff($array, array($file_to_remove));
$this->session->set_userdata('photo',$dataF);
}
else
{
$this->listFiles();
}
}

N-tier navigation in codeigniter

How to create top navigation in code-igniter?
In controller I have declare a function and call model
private function getNavigation(){
$this->load->model('xx');
$data['nav'] = $this->xx->prepareTree();
$this->load->view('index',$data);
}
And In model I have declare three functions
public function prepareTree(){
$this->db->select("`catalog_parent` as parent_id, `catalog_name` as menu_item, `catalog_id` as id, `catalog_template` as pager_id");
$this->db->from("catalog_category");
$this->db->where("`catalog_navigation` = '1'");
$this->q = $this->db->get();
$create = '';
if ($this->q->num_rows() > 0) {
$create = $this->prepareList($this->q->result_array());
}
if(!empty($create)){
return $this->category_tree($create);
} else {
return '';
}
}
private function prepareList(array $items, $pid = 0) {
$output = array();
foreach ($items as $item) {
if ((int) $item['parent_id'] == $pid) {
if ($children = $this->prepareList($items, $item['id'])) {
$item['children'] = $children;
}
$output[] = $item;
}
}
return $output;
}
private function category_tree($menu_items, $child = false){
$output = '';
if (count($menu_items)>0) {
$output .= ($child === false) ? '<ul id="main-menu" class="sm sm-blue">' : '<ul>' ;
foreach ($menu_items as $item) {
$output .= '<li>';
$output .= ''.$item['menu_item'].'';
if (isset($item['children']) && count($item['children'])) {
$output .= $this->category_tree($item['children'], true);
}
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
If some suggest an more easy way please suggest us.
Thanks

Magento Issues with category dropdown

I need to display all the subcategories under root category name using . I am unable to find the root category details. Root category name is displaying as '/' How to overcome this issue?
Currently i am getting all the categories including root categories (/).
My code is as in below:
public function toOptionArray()
{
$categories = array();
$categoryCollection = Mage::getResourceModel('catalog/category_collection')->addFieldToFilter(
'path',
array('neq' => '1')
);
foreach ($categoryCollection as $category) {
var_dump($category->getData());
echo '<br />';
$category = Mage::getModel('catalog/category')->load($category->getId());
$categories[$category->getId()] = $category->getUrlPath();
}
return $categories;
}
protected function _renderOptions(Varien_Object $row)
{
$categories = $this->getColumn()->getOptions();
$html = sprintf('<select class="category_select" name="mapping[%s]">', $row->getData('reference_id'));
$html .= '<option value=""></option>';
foreach ($categories as $id => $name) {
$html .= sprintf(
'<option value="%s"%s>%s</option>',
$this->escapeHtml($id),
$id == $row->getData('category_id') ? ' selected="selected"' : '',
$this->escapeHtml($name)
);
}
$html .= '</select>';
return $html;
}
I need to add into the category dropdown, which is subcategories displaying under root category name.
Can anyone help me please.
Thank You.
I fixed the issue using following:
protected function _renderOptions(Varien_Object $row)
{
$categories = $this->getColumn()->getOptions();
$parentIdArray = array();
foreach ($categories as $id => $name) {
$category = Mage::getModel('catalog/category')->load($id);
$parentId = $category->getParentId();
if($parentId == 1){
$parentIdArray[] = $id;
}
}
$html = sprintf('<select class="category_select" name="mapping[%s]">', $row->getData('reference_id'));
$html .= '<option value=""></option>';
foreach ($parentIdArray as $parentId) {
$parentCategory = Mage::getModel('catalog/category')->load($parentId);
$name = $parentCategory->getName();
$html .= sprintf(
'<optgroup label="'.$name.'">
<option value="%s"%s>%s</option>
</optgroup>',
$this->escapeHtml($parentId),
$parentId == $row->getData('category_id') ? ' selected="selected"' : '',
$this->escapeHtml($name)
);
$categories = Mage::getModel('catalog/category')->getCategories($parentId);
$subCategories = $this->get_categories($categories);
foreach ($subCategories as $id => $name) {
$html .= sprintf(
'<option style="padding-left: 10px;" value="%s"%s>%s</option>',
$this->escapeHtml($id),
$id == $row->getData('category_id') ? ' selected="selected"' : '',
$this->escapeHtml($name)
);
}
}
$html .= '</select>';
return $html;
}
public function get_categories($categories) {
$subCategories = array();
foreach($categories as $category) {
$subCategory = Mage::getModel('catalog/category')->load($category->getId());
$subCategories[$subCategory->getId()] = $subCategory->getUrlPath();
if($category->hasChildren()) {
$children = Mage::getModel('catalog/category')->getCategories($category->getId());
$childrenCategories = $this->get_categories($children);
foreach ($childrenCategories as $id => $name) {
$subCategories[$id] = $name;
}
}
}
return $subCategories;
}

Call to Get Category Images & Display in List

I currently have this set up to display my catalog images in a magento custom grid - I seem to be close but cannot seem to call the final image url to display- can anyone help me?
I have tried calling them from /media/remote/cache also but to no avail :-(
public function render(Varien_Object $row) {
$p = Mage::getModel('catalog/product')->load($row->getproduct_id());
$html = '<img src="' . Mage::getBaseUrl('media').'catalog/product/'.'" width="50" height="50" alt="' . $p->getname() . '" />';
return $html;
}
you have to create your custom render like below
just add this to your grid
$this->addColumn('thumbnail',
array(
'header'=> Mage::helper('catalog')->__('Thumbnail'),
'type' => 'image',
'width' => '100',
'index' => 'thumbnail',
'renderer' => 'NAMESPACE_YOURMODULE_Block_Widget_Grid_Column_Renderer_Image',
));
and create render class at
\NAMESPACE\YOURMODULE\Block\Widget\Grid\Column\Renderer\Image.php
and add below code to this files with proper class name
class NAMESPACE_YOURMODULE_Block_Widget_Grid_Column_Renderer_Image
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
protected static $showImagesUrl = null;
protected static $showByDefault = null;
protected static $imagesWidth = null;
protected static $imagesHeight = null;
protected static $imagesScale = null;
public function render(Varien_Object $row)
{
return $this->_getValue($row);
}
protected static function initSettings()
{
if(!self::$showImagesUrl)
self::$showImagesUrl = (int)Mage::getStoreConfig('yourmodule/images/showurl') === 1;
if(!self::$showByDefault)
self::$showByDefault = (int)Mage::getStoreConfig('yourmodule/images/showbydefault') === 1;
if(!self::$imagesWidth)
self::$imagesWidth = Mage::getStoreConfig('yourmodule/images/width');
if(!self::$imagesHeight)
self::$imagesHeight = Mage::getStoreConfig('yourmodule/images/height');
if(!self::$imagesScale)
self::$imagesScale = Mage::getStoreConfig('yourmodule/images/scale');
}
protected function _getValue(Varien_Object $row)
{
self::initSettings();
$noSelection = false;
$dored = false;
if ($getter = $this->getColumn()->getGetter())
{
$val = $row->$getter();
}
$val = $val2 = $row->getData($this->getColumn()->getIndex());
$noSelection = ($val == 'no_selection' || $val == '') ? true : $noSelection;
$url = Mage::helper('yourmodule')->getImageUrl($val);
if(!Mage::helper('yourmodule')->getFileExists($val))
{
$dored = true;
$val .= "[*]";
}
$dored = (strpos($val, "placeholder/")) ? true : $dored;
$filename = (!self::$showImagesUrl) ? '' : substr($val2, strrpos($val2, "/")+1, strlen($val2)-strrpos($val2, "/")-1);
$val = ($dored) ?
("<span style=\"color:red\" id=\"img\">$filename</span>") :
"<span>". $filename ."</span>";
$out = (!$noSelection) ?
($val. '<center><a href="#" onclick="window.open(\''. $url .'\', \''. $val2 .'\')" title="'. $val2 .'" '. ' url="'.$url.'" id="imageurl">') :
'';
$outImagesWidth = self::$imagesWidth ? "width='".self::$imagesWidth."'":'';
if(self::$imagesScale)
$outImagesHeight = (self::$imagesHeight) ? "height='".self::$imagesHeight."'":'';
else
$outImagesHeight = (self::$imagesHeight && !self::$imagesWidth) ? "height='".self::$imagesHeight."'":'';
//return '<img src="'.(Mage::helper("catalog/image")->init($productItem, "small_image")->resize(self::$imagesWidth)).'" '.$outImagesWidth.' '.$outImagesHeight.' alt="" />';
$out .= (!$noSelection) ?
"<img src=".(Mage::helper("catalog/image")->init($row, $this->getColumn()->getIndex())->resize(self::$imagesWidth))." ".$outImagesWidth." ".$outImagesHeight." border=\"0\"/>" :
// "<img src=".$url." ".$outImagesWidth." ".$outImagesHeight." border=\"0\"/>" :
// "" :
"<center><strong>[".__('NO IMAGE')."]</strong></center>";
return $out. ((!$noSelection)? '</a></center>' : '');
}
hope this will sure help you.

Show admin labels of attribute options of configurable products

I want to show the attribute values of the configurable product on product listing page. I specifically need admin labels of the attribute options which are assigned to particular product.
In my case the attribute name is confi_color. So on list.phtml
if($_product->getTypeId()=='configurable'){
$colorList = array();
$attrs = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
foreach($attrs as $attr) {
if(0 == strcmp("config_color", $attr['attribute_code'])) {
$options = $attr['values'];
$arr = array();
$count = 0;
foreach($options as $option) {
//print_r($option);
$arr[$count] = $option['value_index'];
$count++;
}
$colorList = $_product->getAdminAttributeText($attr['attribute_id'],$arr);
//echo getAdminAttributeText($attributeCode);
}
}
echo '<div style="float:right;">';
if(count($colorList > 1)){
for($i=1;$i<count($colorList);$i++) {
echo '<div style="background:'.$colorList[$i].';float:left;display:block;width:16px;border:1px solid #B6B6B6;margin-right:2px;"> </div>';
//$optStr .= "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()."</option>";
}
echo '</div><div style="clear:left;"></div>';
}
}
Now to get the admin labels in /app/code/core/Mage/Catalog/Model/Product.php to /app/code/local/Mage/Catalo
g/Model/Product.php crete a function:
public function getAdminAttributeText($attributeCode,$arr) {
$_attribute= $this->getResource()->getAttribute($attributeCode);
$_options= $_attribute->getSource()->getAllOptions(true, true);
$count = 0;
$flag = 0;
$returnArr = array();
foreach($_options as $option){
for($count=0;$count<=count($arr);$count++){
if ($option['value'] == $arr[$count]){
$returnArr[$flag] = $option['label'];
$flag++;
}
}
}
return($returnArr);
}

Resources