Jump to content

PraveenShahi

Members
  • Posts

    6
  • Joined

  • Last visited

About PraveenShahi

  • Birthday 07/03/1987

Profile Information

  • Location
    India
  • Activity
    Project Owner

PraveenShahi's Achievements

Newbie

Newbie (1/14)

0

Reputation

2

Community Answers

  1. Hello everyone can someone help me on this, i am trying to use Prestashop Objectmodel class for Adding, Deliting, Updating and Viewing Data from database, i have achieved retrieving data and displaying it on backoffice Form while clicking Edit button / deliting it from backoffice by clicking Delete option but stuck on saving or Updating it, here is my codes Class file <?php class TestiBlock extends ObjectModel { public $id_blocktesti; public $id_lang; public $id_shop; public $testi; public $image; public $name; public $rank; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'blocktesti', 'primary' => 'id_blocktesti', 'multilang' => true, 'fields' => array( 'id_lang' =>array('type' => self::TYPE_NOTHING), 'id_shop' =>array('type' => self::TYPE_NOTHING), 'testi' => array('type' => self::TYPE_HTML), 'image' => array('type' => self::TYPE_STRING), 'name' => array('type' => self::TYPE_STRING), 'rank' => array('type' => self::TYPE_STRING), ) ); } here is my code for rendering Form protected function renderForm() { $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); $fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('New Testimonial'), 'image' => '../img/admin/tab-categories.gif', ), 'input' => array( array( 'type' => 'hidden', 'name' => 'id_blocktesti', ), array( 'type' => 'file', 'label' => $this->l('Profile Picture'), 'name' => 'image', 'required' => false, 'hint' => $this->l('Upload a image from your computer.').' (.gif, .jpg, .jpeg '.$this->l('or').' .png)' ), array( 'type' => 'text', 'label' => $this->l('Person\'s Name'), 'required' => false, 'name' => 'name', 'hint' => $this->l('Name of The Person made testimony.') ), array( 'type' => 'text', 'label' => $this->l('Designation or Rank'), 'required' => false, 'name' => 'rank', 'hint' => $this->l('Degignation, Rank or Job Title of person.') ), array( 'type' => 'textarea', 'label' => $this->l('Testimonial'), 'required' => false, 'lang' => false, 'name' => 'testi', 'cols' => 40, 'rows' => 10, 'class' => 'rte', 'autoload_rte' => true, ), ), 'submit' => array( 'title' => $this->l('Save'), ), 'buttons' => array( array( 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'), 'title' => $this->l('Back to list'), 'icon' => 'process-icon-back' ) ) ); if (Shop::isFeatureActive() && Tools::getValue('id_blocktesti') == false) { $fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Testimonial association'), 'name' => 'checkBoxShopAsso_theme' ); } $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = 'blocktesti'; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); foreach (Language::getLanguages(false) as $lang) $helper->languages[] = array( 'id_lang' => $lang['id_lang'], 'iso_code' => $lang['iso_code'], 'name' => $lang['name'], 'is_default' => ($default_lang == $lang['id_lang'] ? 1 : 0) ); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->toolbar_scroll = true; $helper->title = $this->displayName; $helper->submit_action = 'saveblocktesti'; $helper->fields_value = $this->getFormValues(); return $helper->generateForm(array(array('form' => $fields_form))); } and here is code for processing it public function getContent() { $id_info = (int)Tools::getValue('id_blocktesti'); if (Tools::isSubmit('saveblocktesti')) { $info = new TestiBlock((int)$id_info); $info->save(); Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules')); } elseif (Tools::isSubmit('updateblocktesti') || Tools::isSubmit('addblocktesti')) { $this->html .= $this->renderForm(); return $this->html; } else if (Tools::isSubmit('deleteblocktesti')) { $info = new TestiBlock((int)$id_info); $info->delete(); Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules')); } else { $this->html .= $this->renderList(); return $this->html; } } and here is my db structure: CREATE TABLE IF NOT EXISTS ps_blocktesti ( id_blocktesti int(2) unsigned NOT NULL AUTO_INCREMENT, id_lang int(10) unsigned NOT NULL DEFAULT '1', id_shop int(2) unsigned NOT NULL, testi text NOT NULL, image varchar(255) NOT NULL, name varchar(255) NOT NULL, rank varchar(255) NOT NULL, PRIMARY KEY (id_blocktesti) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS ps_blocktesti_lang ( id_blocktesti int(11) NOT NULL, id_shop int(10) NOT NULL, id_lang int(10) NOT NULL, text text NOT NULL, PRIMARY KEY (id_blocktesti) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Any help would be highly appreciated, thanks in advance. PS Note i am using blockcmsinfo module for above project.
  2. found this one working, thanks everyone php code: global $smarty; $sql = 'SELECT * FROM `'._DB_PREFIX_.'table` '; $sql1= Db::getInstance()->executeS($sql); $smarty->assign('contacts', $sql1); tmp file {section name=co loop=$contacts} <li> <p>{$contacts[co].value1}</p> <div class="cd-author"> <img src='{$contacts[co].value2}' alt="Author image"> <ul class="cd-author-info"> <li>{$contacts[co].name}</li> <li>{$contacts[co].rank}</li> </ul> </div> </li> {sectionelse} <h3>No Data found</h3> {/section}
  3. hey sorry for long delay, anyhow this is how i solved it: rename ur shop url in my case www.mywebsite.com/Prestashop" to "www.mywebsite.com/shop" now go to mysql manager or phpmyadmin> locate your prestashop database> find and open table named : ps_shop_url (here ps is ur db short name )>find and edit cells in my case i hd only updated physical_url from prestashop to shop. you can also edit domain name likewise bye editing domain cell( never tried changing domain though it worked on localhost) enjoy
  4. Hello everyone, can someone please guide me whats wrong in this part sometimes its fetching all data from database, sometime only first row and sometimes nothing..any help or alternate method will be highly appreciated.Thanks in advance here is my-module/mymodule.php: public function hookHome($params) { $this->context->controller->addCSS($this->_path.'css/style.css', 'all'); $this->context->controller->addJS($this->_path.'js/main.js', 'all'); if (!$this->isCached('my-module.tpl', $this->getCacheId())) { $infos = $this->getInfos($this->context->language->id, $this->context->shop->id); $this->context->smarty->assign(array('infos' => $infos, 'nbblocks' => count($infos))); } return $this->display(__FILE__, 'my-module.tpl', $this->getCacheId()); } public function getInfos($id_lang, $id_shop) { $sql = 'SELECT * FROM `'._DB_PREFIX_.'table1` '; return Db::getInstance()->executeS($sql); } and here is my my-module/mymodule.tmp: <div class="my-class"> <ul class="my-class-child"> {if $infos|@count > 0} {foreach from=$infos item=info} <li> <p>{$info.id}</p> <div class="cd-author"> <img src='{$info.image}' alt="my-img"> <ul class="csd"> <li>{$info.value1}</li> <li>{$info.value2}</li> </ul> </div> </li> {/foreach} {/if} </ul> </div> here is my table structure table 1: ----------------------------------------------- id | image | value1 | value2 ----------------------------------------------- 1 | x.jpg | abc | xyz ---------------------------------------------- 2 | x.jpg | abc | xyz ----------------------------------------------
  5. Hello Everyone I am new on Prestashop and i want to know how to change PrestaShop installed url name. for example if present directory url is-" www.mywebsite.com/Prestashop" how to make it load on "www.mywebsite.com/shop". I did find methods on forum and changed database table "ps_shop_url" value to shop, url "www.mywebsite.com/shop" is loading like charm but none of the image or links are working (product image is not showing also categories were not opening). i did inspected image url and everything looks to be okey with url. Sorry for bad English. any help would be highly appreciated. Thanks in advance.
×
×
  • Create New...