* @copyright 2012-2019 SeoSA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class AttachmentTabMEP extends BaseTabMEP { public $attachments; public $old_attachment; public function __construct() { parent::__construct(); $this->attachments = $this->getIntvalArrayRequest('attachments'); $this->old_attachment = (int)Tools::getValue('old_attachment'); } public function applyChangeBoth($products, $combinations) { } public function applyChangeForProducts($products) { foreach ($products as $id_product) { MassEditTools::attachToProduct( $id_product, $this->attachments, $this->old_attachment ); } return array(); } public function applyChangeForCombinations($products) { } public function checkBeforeChange() { if (!is_array($this->attachments) || !count($this->attachments)) { LoggerMEP::getInstance()->error($this->l('No attachments')); } if (LoggerMEP::getInstance()->hasError()) { return false; } return true; } public function getTitle() { return $this->l('Attachments'); } public function assignVariables() { $variables = parent::assignVariables(); $variables['attachments'] = Attachment::getAttachments( $this->context->language->id, 0, false ); return $variables; } }