Page 1 of 1

Category Image

Posted: Wed Feb 18, 2009 10:28 pm
by tifosi
v1.1.7

1. When creating a category the image is being auto selected from the first alphabetical image instead of 'no image'. No image is not 'selected' by default and is also showing up as an image when deleting images.

Re: Category Image

Posted: Wed Feb 18, 2009 11:12 pm
by fido-x
In "admin/model/catalog/image.php", change line 58 from --

Code: Select all

$sql .= " ORDER BY id.title";
to

Code: Select all

$sql .= " ORDER BY i.image_id";
And line 78 from --

Code: Select all

$query = $this->db->query("SELECT * FROM image i LEFT JOIN image_description id ON (i.image_id = id.image_id) WHERE id.language_id = '" . (int)$this->language->getId() . "' ORDER BY id.title");
to

Code: Select all

$query = $this->db->query("SELECT * FROM image i LEFT JOIN image_description id ON (i.image_id = id.image_id) WHERE id.language_id = '" . (int)$this->language->getId() . "' ORDER BY i.image_id");
Make sure you clear your cache and image/cache folders.

This will change to sort order to sort by image_id rather than name. Since the "no image" image has the lowest image_id, it will display first.

Fido-X.

Re: Category Image

Posted: Thu Feb 19, 2009 6:49 pm
by tifosi
Thanks. That's a workaround, but I was thinking more of a change of core logic.

Making the 'no image' a system default for category/product and removing it from any image listings. It would also get around any possible tug-of-war confusions when deleting manufacturers/categories/products where the image is set as 'no image'.

In a similar way to manufacturer select being:
--None---
man-a
man-b
man-c
etc

The image listing would be
--No Image--
image-a
image-b
image-c

with the 'no-image' image selected by default for all cat/prod. It looks and feels neater.

One for Daniel.

Re: Category Image

Posted: Thu Feb 19, 2009 11:07 pm
by fido-x
The "core logic", as you put it, is to select the first image in the list.

As for any "tugs of war", this only occurs if you try to delete an image that is attached to a manufacturer, category or product. There is no "tug of war" when deleting the manufacturer, category or product unless the image is deleted as well (which isn't the case).

However, you could try this --
In "admin/controller/catalog/category.php" find (around line 206)

Code: Select all

$this->load->model('catalog/image');
insert the following after this line:--

Code: Select all

$this->data['no_image'] = $this->model_catalog_image->getImage(33);
Then in "admin/view/template/catalog/category_form.tpl" find

Code: Select all

<select name="image_id" id="image_id" class="image" onchange="$('#image').load('index.php?route=catalog/image/thumb&image_id=' + this.value);">
insert the following after this line:--

Code: Select all

<option value="<?php echo $no_image['image_id']; ?>"><?php echo $no_image['title']; ?></option>
This will give you image 33 (the "no image" image) as the default -- regardless of sort order.

Fido-X.