×
Sign In

This Post is about cleaning out extra media images that are created by Magento’s functionality.

For better understanding, consider a case where we upload CSV of 1000 products, each containing one main image and also one thumb image. So, there would 2000 images uploaded in media folder at location ‘media/catalog/product/…’

Imagine if you set up a cron that uploads products from some CSV file everyday at midnight. It’s not the case that you are going to add/update/delete products everyday. So, if you have not updated anything for one week in CSV file, which is going to be run everyday using cron and products are going to be imported everyday for that whole week. But as the product_id would be same for the products that are not changed in any means, duplicate product would not be created. But the images would be duplicated and copied to ‘media/catalog/product/…’

Consider a case, for a product with images abc.jpg and abc_thumb.jpg. Now, when the same product is uploaded again, then abc_1.jpg and abc_thumb_1.jpg are created in ‘media/catalog/product/…’. Likewise after the whole week, images would be created as abc_2.jpg and abc_thumb_2.jpg and it continues until the last day of the week.

So, after 1 week, 2000 images would be now 14000 images. Just imagine what it would after 1 month, if old products are still there in CSV file that is uploaded by cron everyday. Ultimately, the size of media folder would increase day by day and server memory for our site would also increase. This may cause many serious problems.So, to avoid such problems, extra images from ‘media/catalog/product/…’ should be deleted of those images, whose entries are not found in db.

Now, there is one pair of image for each product that is uploaded repetitively.

Further flushing out the images of cache folder that is created by Magento at ‘media/catalog/product/cache’,

Above code would delete the ‘cache’ folder from ‘media/catalog/product/’. So, now, extra catalog images that are created due to Magento cache would be deleted every time.

While uploading process of images using .csv file, Poeple usually create some temporary folder. So, after the images are copied to Magento directory structure, that temporary folder is not needed. To save memory space on server, it is a good practice to delete, all the extra folders, images, etc. So, to delete that temporary folder.

For example temporary folder named ‘import’ in ‘media’ folder of Magento and it contains .csv file and other images that must be deleted at the end.

It can be done through adding following code:

 

Issue Fixed By: Nimit Shah
Guided By: Sunil Patel

This Blog will helpful to add signup for wholesale in your store, you can also learn How to Activate customer through admin, How to assign group to registered user. How to add Custom field into form and add attribute to store.

Whole post is divided in three part

1) Add Link on home page and register form.

2) Assign group to new register user.

3) Add Customer Attribute and Custom For field into form.

4) How to Activate User Through Admin and notify Customer and Admin about new Customer or Wholesaler.

Step 1: How to Add Link and Register form?

Now We will learn to add link as per below.add link to headaer

For that we will Copy the core file into our default folder or template. best practice is edit core file after copying into default folder instead of direct editing into core file.

Follow below step for copy and add link.

Copy core File from location: app/design/frontend/base/default/layout/customer.xml to app/design/frontend/default/default/layout/customer.xml

Add below code to customer.xml

When we click on Wholesale for open registration form it will do nothing. to start working this link we need to create CMS Page.

How to create a CMS Page?

Login into Admin Panel and follow below step

Click on CMS => Pages then

Click on Add New Pages button.

Set “Page Title” and “Url Key” as wholesale.

Now, Click on “Design” tab inside “layout update XML” add below code

Above code will add template to new created page.

Above code will use to show addresss fields into wholesale registration form. if you do not want to add address field then put false instead of true.

Now we, will

Create a register.phtml for wholesale login as per below structure

app/design/frontend/default/default/template/wholesale/customer/form/register.phtml

wholesale_signup

Step 2: How to Assign Group to wholesale or General customer?

Open register.phtml and add below code after line No. 51.

Note: Default value is give as above. but it May be different; put as per your wholesale group value.

How to Find Value:

=> Customer => Manage Customer.

=> in Group click on drop down then count number of Wholesale from first group.

=> whatever number you get it will be your value.

Now open AccountController.php

app/code/core/Mage/Customer/controllers/AccountController.php

Step 3: Add Customer Attribute and Custom field into form.

Add below Code inside register.phtml it will use to add field into your wholesale registration form.

Now, We will see how to add attribute into store.

For that we need to install Customer Attribute Manager. you can download it from here.

Select Customer => Customer Attributes Manager.

Then click on “Add Attribute” button. then follow as per below image.

add_attribute_1

add_attribute_2

Now Save Attribute.

Step 4: How to Activate wholesaler through admin?

Install Customer Activation Module into your store.

For Activate Customer, Select Customer => Manage Customer admin side and select particular customer and

inside “Account information” select “Yes” for is Activated.

For module setting System => Configuration

inside “Customers” tab select “Customer Configuration” and then “Customer Activation” and Enable Module.

=>select Require Activation for Specific Groups only as “Yes” then

=>select “Wholesale” in Require Activation for Groups as per given below Image

Module_Setting

Issue Fixed By: Punit K. Gadhiya

Guided By: Jignesh Thummar

Contact Form
Footer Content