ProductSale::getBestSalesLight
خیلی ساده ابتدا نام کلاس و سپس نام تابع را در ماژول می اوریم
ProductSale::getBestSalesLight
خیلی ساده ابتدا نام کلاس و سپس نام تابع را در ماژول می اوریم
۱.اضافه کردن install
'HOOK_SLIDESHOWLM' => Hook::exec('slideshowlm'),
۲.اضافه کردن به کنترلر controller
IndexController.php مثلا
$this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'),
'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'),
'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent'),
'HOOK_SLIDESHOWLM' => Hook::exec('slideshowlm'),
));
۳.اضافه کردن به index.tpl
{if isset($HOOK_SLIDESHOWLM)}{$HOOK_SLIDESHOWLM} {/if}
public function hookHeader($params) {
$rand = mt_rand(1, 1000);
$namefile = "dycss" . $rand . ".css";
$myfile = fopen("modules/lmslideshow/css/" . $namefile, "w");
$txt = "
h1 {
color: maroon;
margin-left: 40px;
}
";
fwrite($myfile, $txt);
fclose($myfile);
$this -> context -> controller -> addCSS(($this -> _path) . 'css/' . $namefile, 'all');
$this -> context -> controller -> addCSS(($this -> _path) . 'css/boom.css', 'all');
$this -> context -> controller -> addJS(($this -> _path) . 'js/boom.js');
}
این کار روش های مختلفی دارد ولی یک روش آن به شرح زیر است :
اضافه کردن hook header در هنگام install
!$this -> registerHook('home')
اضافه کردن به هوک header
public function hookHeader($params)
{
$this->context->controller->addCSS(($this->_path).'boom.css', 'all');
$this->context->controller->addJS(($this->_path).'js/boom.js');
}
توجه کنید که فایل های boom باید وجود داشته باشند و خالی نباشند.
http://blog.belvg.com/prestashop-modules-stylization.html
در پرستاشاپ می توان مدل برای ارتباط با دیتابیس به طور کلی نوشت و مبحث چند زبانی را کاملا با lang , multilang= true _ حل کرد
و برای ارتباط های چند گانه و نمایش در فرم ادمین باید جداگانه کوئری زد .
$this->_select = ' cl.* ';
$this->_join .=
'LEFT JOIN `ps_category_lang` as cl ON (a.`id_category` = cl.`id_category` )
';
// add action on list
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->addRowAction('details');
// create list
$this->fields_list = array(
'id_lmslideshow' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
),
'name' => array(
'title' => $this->l('ID Category'),
'width' => 25,
'filter_key' => 'a!name',
)
);
و برای قسمت ویرایش از option استفاده نمود
$this->_select = ' cl.* ';
$this->_join .=
'LEFT JOIN `ps_category_lang` as cl ON (a.`id_category` = cl.`id_category` )
';
// add action on list
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->addRowAction('details');
// create list
$this->fields_list = array(
'id_lmslideshow' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
),
'name' => array(
'title' => $this->l('ID Category'),
'width' => 25,
'filter_key' => 'a!name',
)
);
https://books.google.com/books?id=BsSiBQAAQBAJ&pg=PT178&lpg=PT178&dq=prestashop+_join%28%29&source=bl&ots=JCdV6nBcjq&sig=5jTC4Xeeu1WvfhMJOEMStG3TYrk&hl=en&sa=X&ved=0CDMQ6AEwAmoVChMIl_D6msP5xwIVw9YaCh3o5wD6#v=snippet&q=ObjectModel&f=false
http://www.amazon.com/PrestaShop-Module-Development-Fabien-Serny-ebook/dp/B00QFBNXIO
https://www.packtpub.com/web-development/prestashop-module-development
http://www.amazon.com/gp/search?index=books&linkCode=qs&keywords=9781326399085
https://books.google.com/books?id=0hx7CgAAQBAJ&pg=PA127&lpg=PA127&dq=fields_list+filter_key&source=bl&ots=dETGKy0mZM&sig=RicAKHDjjUT4doEIqdKq__FsgGI&hl=en&sa=X&ved=0CFsQ6AEwCWoVChMIiI-e1rn7xwIVgZwsCh1jvAdW#v=onepage&q=fields_list%20filter_key&f=false
global $smarty, $cookie, $link;
$id_customer = (int)$params['cookie']->id_customer;
$id_group = $id_customer ? Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
$id_lang = (int)$params['cookie']->id_lang;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.*, cl.*
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
WHERE level_depth > 1 And level_depth < 3
AND c.`active` = 1
AND cg.`id_group` = '.$id_group.'
ORDER BY `level_depth` ASC, c.`position` ASC');
$category = new Category(1);
$nb = intval(Configuration::get('HOME_categories_NBR'));
global $link;
$this->context->smarty->assign(array(
'categories' => $result, Category::getRootCategories(intval($params['cookie']->id_lang), true),
'link' => $link));
{foreach $categorys as $category}
{$category.name}
<img src="{$link->getCatImageLink($category.link_rewrite, $category.id_category )|escape:'html':'UTF-8'}" />
{/foreach}
<ul> {foreach $myPeople as $value} <li>{$value@key}: {$value}</li> {/foreach} </ul>
http://blog.belvg.com/objectmodel-activerecord-in-prestashop.html
Configuration::get('PS_LANG_DEFAULT')
$parent_id = Configuration::get('PS_HOME_CATEGORY');
http://doc.prestashop.com/display/PS16/Using+the+HelperForm+class
http://nemops.com/prestashop-categories-second-image/#.VfbOs7MabCJ
http://stackoverflow.com/questions/26582252/display-all-categories-on-product-page-prestashop
https://www.prestashop.com/forums/topic/278116-tutorial-displaying-list-of-categories-and-products-in-any-tpl/
$product = new Product($id); $categories = $product->getCategories();
To set them:
$product = new Product($id); $success = $product->updateCategories(array('1','3','4')) $product->id_category_default = '3'; $product->update();
https://www.prestashop.com/forums/topic/247361-solved-altering-products-categories-in-database/
http://flowcoding.com/prestashop-create-first-module
http://www.technoreply.com/how-to-create-a-prestashop-1-5-module/
https://github.com/jevin/Prestashop-Module-Skeleton
p()
is the main method, and d()
works the same way, except that it calls the die()
method instead of returning the variable:
of that, PrestaShop defines the ppp()
and ddd()
methods, which are respectively the aliases of p()
and d()
. They work exactly the same, but are often easier to search and find in a huge block of code.
ppp()
ddd()
These debug methods are not activated by default. To activate them, you must enable the Debug mode, by setting _PS_MODE_DEV_
to true
(see above).
http://doc.prestashop.com/display/PS16/Setting+Up+Your+Local+Development+Environment
PrestaShop's default settings prevent the customer to see any server error message or any debugging code.
You, on the other hand, need this information in order to correct any potential mistake in your code. To that end, open the /config/defines.inc.php
file, and edit it to set _PS_MODE_DEV_
to true
:
/* Debug only */
define(
'_PS_MODE_DEV_'
,
true
);
Go to the "Performances" page under the "Advanced parameters" menu to change the following Smarty settings:
http://doc.prestashop.com/display/PS16/Setting+Up+Your+Local+Development+Environment
you can find php.ini in
sudo gedit /etc/php5/apache2/php.ini
http://ubuntuforums.org/showthread.php?t=1097306
https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/prestashop2/changing-the-prestashop-url-settings
http://nemops.com/category/tutorials/development/
http://doc.prestashop.com/display/PS16/Developer+Guide
http://doc.prestashop.com/display/PS16/Designer+Guide
http://forum.shopkeeper.ir
http://forum.prestatools.ir/
http://forum.persiantools.com/
http://www.custommyself.com/how-to-create-a-module-with-prestashop/