4

So, I create module, which implement import/export some data. Everything work fine. The logic of import in next : I take a file in var/[module_name]/import/. (This file will be put by some another service)

My question is: What is the best way to create this folders [module_name]/import when some one will take my module in other project?

I think about to write instruction ('create folder in var...'), and also I think about installer, but I guess it is not good idea

Any advice?

9

If you have a separate extension for import/export just add this in the install script of you extension:

$io = new Varien_Io_File();
$io->checkAndCreateFolder(Mage::getBaseDir('var').DS.'[module_name]'.DS.'import');

It will create the folder with 777 permissions.

  • Thanks, but I read something like in installer is only for some issue with db. But, ok thanks again!!) – sergio Mar 6 '14 at 14:05
  • @sergio. yes usually the install script is for changing the db, but it works for folders also. – Marius Mar 6 '14 at 14:07
2

I think that extension which creates files in that folder should take responsibility of creating that folder.

If your extension just reads files from the folder, than you can specify the path to directory as config value and make in editable from backend.

In this case admin could specify in which folder to search import files.

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.