public function installFixtures() { $return = true; $tab_texts = array(array('text' => '<ul> <li><em class="icon-truck" id="icon-truck"></em> <div class="type-text"> <h3>Lorem Ipsum</h3> <p>Lorem ipsum dolor sit amet conse ctetur voluptate velit esse cillum dolore eu</p> </div> </li> <li><em class="icon-phone" id="icon-phone"></em> <div class="type-text"> <h3>Dolor Sit Amet</h3> <p>Lorem ipsum dolor sit amet conse ctetur voluptate velit esse cillum dolore eu</p> </div> </li> <li><em class="icon-credit-card" id="icon-credit-card"></em> <div class="type-text"> <h3>Ctetur Voluptate</h3> <p>Lorem ipsum dolor sit amet conse ctetur voluptate velit esse cillum dolore eu</p> </div> </li> </ul>'), array('text' => '<h3>Custom Block</h3> <p><strong class="dark">Lorem ipsum dolor sit amet conse ctetu</strong></p> <p>Sit amet conse ctetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit.</p>')); $shops_ids = Shop::getShops(true, null, true); $return = true; foreach ($tab_texts as $tab) { $info = new InfoBlock(); foreach (Language::getLanguages(false) as $lang) { $info->text[$lang['id_lang']] = $tab['text']; } foreach ($shops_ids as $id_shop) { $info->id_shop = $id_shop; $return &= $info->add(); } } return $return; }
protected function importInfos() { if (!(int) Validate::isLoadedObject(Module::getInstanceByName('blockcmsinfo')) || !Module::isEnabled('blockcmsinfo') || !Module::isInstalled('blockcmsinfo')) { return; } $new_path = new Sampledatainstall(); $sfile = $new_path->sendPath() . 'input/infos.csv'; if (!is_file($sfile) || !is_readable($sfile) || !class_exists('InfoBlock')) { return; } $this->truncateTables(array('info', 'info_lang')); $handle = $this->openCsvFile('infos.csv'); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) { $res = false; $fields = $this->filterFields('InfoBlock', $this->info_fields, $line); if (!isset($fields['id'])) { $info = new InfoBlock($line[0]); $info->id = $line[0]; } else { $info = new InfoBlock($fields['id']); } foreach ($fields as $key => $field) { if ($key == 'text') { $info->{$key} = $this->multilFild($field); } else { $info->{$key} = $field; } } $info->id_shop = $this->context->shop->id; $info->force_id = true; if (!$res) { $res = $info->add(); } } $this->closeCsvFile($handle); return true; }