Skip to content

Instantly share code, notes, and snippets.

@jahvi
Created November 11, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahvi/08c8f612d72c2d84187a to your computer and use it in GitHub Desktop.
Save jahvi/08c8f612d72c2d84187a to your computer and use it in GitHub Desktop.
Change allowed file extensions per attribute
<?php
public function changeAllowedFileExtensions(Varien_Event_Observer $observer) {
$file = $observer->getEvent()->getFile();
// Assuming 'document' and 'sample_video' are your attribute codes
if ($file->getName() == 'document') {
$file->setData('allowed_extensions', array('pdf'));
} else if ($file->getName() == 'sample_video') {
$file->setData('allowed_extensions', array('mp4', 'mpeg', 'avi'));
}
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment