Prestashop 1.7 hook on admin product - module

I have a error on my custom module.
I need to put a extra text on product admin page.
I have use the hook "hookDisplayAdminProductsMainStepLeftColumnMiddle", and it display my tpl with the info (on the image, it is the text "Información adicional relacionada").
The problem is, when the module is active the product admin page not finish of charge.
So I can't save the product or do anything.
This is the code of the hook
public function hookDisplayAdminProductsMainStepLeftColumnMiddle($params)
{
$product = new Product($params['id_product']);
$this->context->smarty->assign(array(
'product ' => $product,
)
);
return $this->display($this->_path, '/views/templates/admin/admininfo.tpl');
}
If I comment only the line "return ....", of course it doesn't display, but the product page charge properly.
On the tpl I write only a text, I don't put yet even a variable.
The other code seems to works properly. I have commented the javascript code on my module.
Nor errors or warnings on the console or even on logs.
I have actived the debbug mode, but not even there display any error.
Any idea or suggest will be grateful!

Try using :
$tpl = $this->context->smarty->createTemplate(
dirname(__FILE__).'/views/templates/admin/yourtemplate.tpl'
);
And then :
return $tpl->fetch();

Related

hookHeader in Prestashop, breaks flow whatever I do

I want to add a custom js file my_sdk.js in my Prestashop module.
I register the hook header and prepare the function,
but whatever I do inside, breaks something.
My my_sdk.js file is correctly added by addJS() and it works.
The problem is that, after that, the cart is no more updated.
Whatever I write inside the hookHeader, it's executed but then the popup showing after the 'add to cart' action, stops working. The popup doesn't show up and the total amount of the cart is not updated until I refresh the page. It's not a problem of my js file, even if I don't import it and write something else (like an echo), I have the same problem.
It works only if I don't write anything (or comment everything) inside function hookHeader().
public function install() {
return (bool) $this->registerHook(['header']);
}
public function hookHeader($params) {
$this->context->controller->addJS(_PS_MODULE_DIR_ . $this->name . '/views/js/my_sdk.js'); // this line breaks the popup
echo "hello, this breaks the popup"; // also just this line breaks the popup
}
I really don't understand why. Tried also with hookDisplayHeader, same thing. The website works, without errors, but the cart is not updated and the popup doesn't show.

LiveZilla and Prestashop - not displaying on all pages

I have LiveZilla working on my site, but it's connected to the wrong hook. The chatbar only appears when i click on a menu (horizontal bar) it doesn't appear on homescreen / add to cart page or any other page except links on menu bar.
It only lets me hook it to the 'displayleftcollumn or displayrightcollumn' - when i run live edit i can see the module but its only on the menu pages.
I would like the chatbar to be on every page - I'm using the default bootstrap theme
How do i fix this?
site www.shop.tacitskills.com - click on classroom / online etc, the bar appears.
I have tried asking LiveZilla / Prestashop but no response.
You can edit the module php, and include this to add the option for the footer:
public function hookFooter($params)
{
return $this->hookLeftColumn($params);
}
Better yet, create an override file in folder overrides/modules/(modulename)/(modulename).php with
<?php
if (!defined('_PS_VERSION_'))
exit;
class (Modulename)Override extends (Modulename)
{
public function hookFooter($params)
{
return $this->hookLeftColumn($params);
}
}
In (modulename) use the livezilla module folder name.
This way, it will "survive" module updates.
Don't forget to delete the file cache/class_index.php after creating this file.

Checking for Last Page in QWeb Reports in Odoo

Odoo v8 uses Qweb and we need to print the terms and conditions of sale on the last page of the invoice.
As I understand we need to test that it is the last page of the report and print some static HTML on this page.
Does anyone know how to test the last page and remove the header and footer from it to achieve what I am trying.
Or even another way of doing it.
In last version of odoo, version 8 (or saas-6), to enable special class names to do special things (as for instance a 'last-page' class name to trigger visibility), you should only modify report module, in static/src/js/subst.js, and add this code to the subst function:
var operations = {
'last-page': function (elt) { elt.style.visibility = (vars.page === vars.topage) ? "visible" : "hidden"; },
};
for (var klass in operations) {
var y = document.getElementsByClassName(klass);
for (var j=0; j<y.length; ++j) operations[klass](y[j]);
}
In the QWEB ir.ui.views used by your report, you can then add anywhere (header, body, footer), code with:
<div class="last-page">
My content only displayed if on last page.
<div>
EDIT: An OpenERP/Odoo addon to add this magic class last-page easily was implemented as an example: https://github.com/0k/report_extended

Forgot password does not work in magento 1.9.0.1

Hi when customers click on "forgot Password" they receive the email with a link to reset. When clicked this is the error that they are receiving. Fatal error: Call to a member function setCustomerId() on a non-object in /home/ishieldz/public_html/store/app/code/core/Mage/Customer/controllers/AccountController.php on line 750
Any help would be appreciated. Thank you!
/**
* Display reset forgotten password form
*
* User is redirected on this action when he clicks on the corresponding link in password reset confirmation email
*
/
public function resetPasswordAction()
{
$resetPasswordLinkToken = (string) $this->getRequest()->getQuery('token');
$customerId = (int) $this->getRequest()->getQuery('id');
try {
$this->_validateResetPasswordLinkToken($customerId, $resetPasswordLinkToken);
$this->loadLayout();
// Pass received parameters to the reset forgotten password form
$this->getLayout()->getBlock('resetPassword')
->setCustomerId($customerId)
->setResetPasswordLinkToken($resetPasswordLinkToken);
$this->renderLayout();
} catch (Exception $exception) {
$this->_getSession()->addError( $this->_getHelper('customer')->__('Your password reset link has expired.'));
$this->_redirect('/*/forgotpassword');
}
}
If you are in Magento 1.9.1 Here is a solution which worked for me.
If your theme doesn’t include any specific custom config or layout settings you can safely delete your customer.xml (or just rename to customer1.xml) file located at /app/design/frontend/default/<your_theme_package>/<your_theme_name>/layout/customer.xml
If you delete this file magento will load the default config options
(with the updates) from the factory default magento theme.
/app/design/frontend/base/default/layout/customer.xml
Remember to flush / refresh your magento config via administration area, this will force the customer.xml file to be reloaded.
It seems that your invoking an udeclared object, so maybe it's only a variable.
Verify if you're declaring your object before the line 750 in your AccountController.php
You must put the declaration of the object (Example: $ob = new Customer();)
that contains the setCustomerId() method, into the method that is running.
login to magento. go to system, design. Delete your current theme and then re-add again.

Phpbb new successful member registration pop up window

I would like to create a pop up welcome message for the new member that's successfully registered.
But I m having problem of finding where should I put the code, I have check the ucp_register.html ,, but I don't think that is the display content after the member successfully registered, can anyone help me please? Thanks
It would likely to be a more robust solution to display the popup on the first time the user is logged in as an activated user -- after registration they may not be activated, or they may close the browser window immediately after registration.
The way to do this would be to add a column (say, user_JBL_seen_message INT to the phpbb_users table in the database, then modify functions.php to check that column:
In functions.php, find:
// The following assigns all _common_ variables that may be used at any point in a template.
Before, add:
if($user->data['is_registered'] && $user->data['is_active'] && !$user->data['is_bot'])
{
if(isset($user->data['user_JBL_seen_message']) && !$user->data['user_JBL_seen_message']))
{
$showPopup = true;
$sql = 'UPDATE ' . USERS_TABLE . ' SET user_JBL_seen_message = 1
WHERE user_id = ' . (int)$user->data['user_id'];
if (!$result = $db->sql_query($sql))
{
return false;
}
}
}
Then, find:
$template->assign_vars(array(
After, add:
'JBL_POPUP' => $showPopup,
Then, you can add the popup HTML code to your overall_header.html template file, where appropriate...
<!-- IF JBL_POPUP -->
.... your HTML popup code here.....
<!-- END IF -->
If you don't want existing users to see the popup, then fill the new column with 1s.
I also agree with Damien's suggestion to use a jQuery UI dialog rather than a popup -- most users' browsers will block popups. However, use jQuery in noconflict mode to avoid conflicts with other mods.