1

I want to create custom module for "Image Uploader" , and create grid, in this grid , I want to put "Image Title","Image Path", "Image", "Status", "Dropdown (for the selecting image)". once image is uploaded then admin select image from the dropdown for display image on the frontend.

  • so you want we write code for you? you must add what you tried so far? – Qaisar Satti Aug 31 '16 at 5:35
  • no not write whole code. i am created the module , but i want to show images on the frontend page("product detail page"), which image status is enable. – H_Parekh Aug 31 '16 at 6:06
  • did you create the model for that? – Qaisar Satti Aug 31 '16 at 6:07
  • yes i am created a model . – H_Parekh Aug 31 '16 at 6:10
  • i added the sample code for you – Qaisar Satti Aug 31 '16 at 6:16
1

here is sample code get data

 $collections = Mage::getModel('moudlename/modelname')->getCollection()
              ->addFieldToFilter('status', array('eq' => 1));

  foreach($collections as $collection) { ?>
         <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'pathtoimage/'.$collection->getImage(); ?>" >
   <?php } ?>
  • it gives the follwing error – H_Parekh Aug 31 '16 at 6:27
  • Fatal error: Call to a member function getCollection() on a non-object in – H_Parekh Aug 31 '16 at 6:27
  • did you change these are you model ('moudlename/modelname')? – Qaisar Satti Aug 31 '16 at 6:28
  • 1
    Mage::getModel('image/upload')->getCollection() try this – Qaisar Satti Aug 31 '16 at 6:37
  • 1
    try this Mage::getModel('upload_image/upload')->getCollection() – Qaisar Satti Aug 31 '16 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.