Post by genegrin » Thu Jan 12, 2012 6:21 am

It would take many hours if i'll select and delete images one by one.
Any ideas please.
Thanks.

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by MarketInSG » Thu Jan 12, 2012 9:10 am

Access your website via FTP client. Browse to your image folder and delete from there. You can use filezilla if you don't know any FTP client to use.


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by straightlight » Thu Jan 12, 2012 9:52 am

MarketInSG wrote:Access your website via FTP client. Browse to your image folder and delete from there. You can use filezilla if you don't know any FTP client to use.
I wouldn't recommend this methodology since the images may be deleted quickly but the relation entity on the database involving all these images wouldn't be deleted as it would only take useless place in the SQL tables. The best option would be to replace all these images by another image which would rather confirm the specific orders has been processed and completed so for the merchant to have a better understanding between each orders.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Thu Jan 12, 2012 11:24 pm

Thanks to all for the answers.

Straightlight, I didn't know that images' information wouldn't delete from the SQL. It means ftp clients is a bad idea.

I tried to add this code to admin/controller/catalog/product.php
Code:
$query = $this->model_catalog_product->getProduct($product_id);
if (file_exists(DIR_IMAGE . $query->row['image'])) {
@unlink(DIR_IMAGE . $query->row['image']);
}
However this stuff didn't work corretly. Please maybe somebody can advise me how to add the code right?

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by straightlight » Thu Jan 12, 2012 11:28 pm

It would only delete from database amongst with the files if queried from the code you posted above, obviously, but not manually deleted from files towards SQL which means the relation from the database so to load all the images would be corrupted data which is what makes it the bad idea.

Now, when stating didn't work correctly, could you be more specific ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Fri Jan 13, 2012 12:04 am

i added that code above this line;
$this->model_catalog_product->deleteProduct($product_id);
but it show an error when i delete a product.

Please my currently code is;
$this->load->model('catalog/product');
if (isset($this->request->post['selected']) && $this->validateDelete()) {
foreach ($this->request->post['selected'] as $product_id) {
$this->model_catalog_product->deleteProduct($product_id);
}
What do i have to add there? will it work if a sold product has a few images to delete?

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by straightlight » Fri Jan 13, 2012 12:06 am

but it show an error when i delete a product.
What does the error message ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Fri Jan 13, 2012 12:29 am

Parse error: syntax error, unexpected T_PUBLIC in /home/randttre/public_html/admin/controller/catalog/product.php on line 178

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by straightlight » Fri Jan 13, 2012 12:31 am

Missing bracket which confuses the current method you're working on in that controller file.

Code: Select all

if (isset($this->request->post['selected']) && $this->validateDelete()) {
 foreach ($this->request->post['selected'] as $product_id) {
 $this->model_catalog_product->deleteProduct($product_id);
}
for:

Code: Select all

if (isset($this->request->post['selected']) && $this->validateDelete()) {
    foreach ($this->request->post['selected'] as $product_id) {
        $this->model_catalog_product->deleteProduct($product_id);
    }
}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Fri Jan 13, 2012 12:47 am

so please what the whole code must look like?

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by straightlight » Fri Jan 13, 2012 1:11 am

I ... posted the code on the above so please read look at it.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Fri Jan 13, 2012 1:57 am

now i get this stuff;
Notice: Trying to get property of non-object in /home/randttre/public_html/admin/controller/catalog/product.php on line 129Notice: Trying to get property of non-object in /home/randttre/public_html/admin/controller/catalog/product.php on line 130Warning: unlink(/home/randttre/public_html/image/) [function.unlink]: Is a directory in /home/randttre/public_html/admin/controller/catalog/product.php on line 130Warning: Cannot modify header information - headers already sent by (output started at /home/randttre/public_html/admin/index.php:72) in /home/randttre/public_html/system/engine/controller.php on line 27

the current code is;
$this->document->title = $this->language->get('heading_title');

$this->load->model('catalog/product');

if (isset($this->request->post['selected']) && $this->validateDelete()) {
foreach ($this->request->post['selected'] as $product_id) {
$query = $this->model_catalog_product->getProduct($product_id);
if (file_exists(DIR_IMAGE . $query->row['image'])) {
@unlink(DIR_IMAGE . $query->row['image']);
}
$this->model_catalog_product->deleteProduct($product_id);
}

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by straightlight » Fri Jan 13, 2012 2:10 am

Please post your admin/controller/catalog/product.php file as an attachment instead of posting partial codes.

As for this error message:

Code: Select all

Warning: unlink(/home/randttre/public_html/image/) [function.unlink]: Is a directory
it means you did not properly set CHMOD permission settings from that directory in order for OpenCart to be able to write on it. Assure to set the proper setting permission value on that directory. This should fix the problem.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Fri Jan 13, 2012 2:31 am

please look on the file

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by straightlight » Fri Jan 13, 2012 2:46 am

In admin/model/catalog/product.php file,

find:

Code: Select all

public function deleteProduct($product_id) {
add right after:

Code: Select all

$product_images = $this->getProductImages($product_id);
		
		if ($product_images->num_rows) {
			foreach ($product_images->rows as $product_image) {
				if (file_exists(DIR_IMAGE . $product_image['image'])) {
					@unlink(DIR_IMAGE . $product_image['image']);
				}
			}
		}
Remove the partial code posted from your previous post from the controller so to avoid doing this process twice during the same operation as only from the model it would be needed in this case.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Fri Jan 13, 2012 3:10 am

could you please attach the file with the correct code?

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by straightlight » Fri Jan 13, 2012 3:23 am

Simply follow the above code. Core files aren't supposed to get modified on anyhow.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Fri Jan 13, 2012 3:56 am

i didn't find this line in the product.php
public function deleteProduct($product_id) {

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am

Post by straightlight » Fri Jan 13, 2012 5:07 am

The modifications above are for v1.5.1.3.1 release. Which version are you using ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by genegrin » Fri Jan 13, 2012 5:37 am

Version 1.4.9.3

Active Member

Posts

Joined
Wed Jun 08, 2011 3:00 am
Who is online

Users browsing this forum: No registered users and 25 guests