I’ve installed magento edition version 1.9.2.0 and added a custom attribute pdf(text field) and adding pdf names for each product using this attribute and manually adding pdf file in the media/PDF folder.Now i want to delete the unwanted pdf files(not in database) .please suggest any option for this.
1 Answer
We assume that your attribute (PDF) default value is 0 or 'null'.Now you have to get those products which have values in the database. You need to get them from product collection on the basis of attribute filter after you can delete files other than the resultset values.
$collection = Mage::getModel('catalog/product')->getCollection();
//filter product by attribute value
$collection->addAttributeToFilter(
array(
array('attribute'=> 'pdf','neq' => '0'),
array('attribute'=> 'pdf','neq' => '')
);
-
thank you for your answer.but i need this works like Imaclean module.ie, in the backend user can list unwanted files names and can delete selected items.any module available for this?– AshaJun 1, 2016 at 4:00
-
The plugin image clean ( hopefully you have already looked at) suite to your requirement but you have to customize this module according to your requirements.– user40382Jun 1, 2016 at 8:13