I have created custom admin controller in my custom module but i am not able to use Context::getContext() in my admin controller.
When i try to use that i am getting below error.
Attempted to call an undefined method named "getContext" of class "PrestaShop\PrestaShop\Adapter\Shop\Context".
Did you mean to call e.g. "getContextListShopID", "getContextListShopIDUsingCustomerSharingSettings", "getContextShopGroup" or "getContextShopID"?
I have already added this line at the top of my file use PrestaShop\PrestaShop\Adapter\Shop\Context;
but still facing same issue.
If anyone have any idea why Context::getContext() doesn't work I would like to hear it.
Thanks
Related
I have succesfully used Yii2 Model & CRUD Generators to obtain some skeleton code files for my web app. Particularly, the CRUD Generator claims to have succesfully created its view files into:
<yii_root>/basic/views/<my_view_name>/*.php
which I got by leaving "View Path" field blank.
However, browsing to:
https://<my_site_FQDN>/basic/web/index.php?r=<my_view_name>/index
spits a "Not Found (#404)" error and I'm unable to find any useful info in the Yii2 debug logs.
Any idea on this matter shall be welcome.
Antonio
<my_view_name> this is a terrible way of looking at this. Read about MVC.
You are creating controllers, routes are to controllers not to views. Stop looking if the views are there... look if the controller is there. You never interact with a view, you always do with a controller. So, is your controller there? are you sure you have created it?
Also what is the controller name? if you have something like ProductCategory then the correct route is
https://<my_site_FQDN>/basic/web/index.php?r=product-category/index
and not
https://<my_site_FQDN>/basic/web/index.php?r=ProductCategory/index
Edit
Ok, I see your problem, stop putting folders under other folders and so on. You created your CRUD wrong. Your controller has to be directly under controllers not under controllers/bibliografia, the same goes for the model. Delete the files and start again with CRUD as probably your namespaces are also wrong.
In my case, Yii2 consistenly writes the following with gii CRUD auto-generator.
namespace app\Controllers;
Notice uppercase 'C' for Controllers. This causes 404 error.
It should be :
namespace app\controllers
This fixed my 404 error.
I found with Yii2 (advanced template) that the generated controllers had:
namespace app\controllers;
I had to change this to:
namespace frontend\controllers;
I fixed it by capitalizing the first letter of the controller name.
Controller name should start with capital letters.
If lower case is used, Controller generator won't throw any error, but you will get not found(404) error in the browser.
this threw an error:
app\controllers\testController
this worked:
app\controllers\TestController
Its very Simple, change the namespace and please be careful while creating CRUD..
change namespace app\controllers; to namespace backend\controllers;
Good afternoon,
I don't know if what I want to do is possible, so here goes.
I have a module that extends Page_Controller, but I want certain functions to be accessible via the site root.
Eg: getMyDataObjectList();
Currently, they only work if I go through the normal MVC routing structure.
I've found that when I place the function 'getMyDataObjectList' within '/mysite/code/Page.php' it works.The problem is, I don't want to place the code in there. I want it bundled with my Custom Module, but to work the same as though it was in 'mysite/code/Page.php'
[Example Scenario]
site root: http://[somesite].com
By default, the 'Page.ss' template loads.
I would like the theme developer to be able to call my module functions (API) within any template/Layout page, and have the result returned from the site root
Currently, this only works if I move the "API" functions to '/mysite/code/Page.php'
If the code is in my module, then data is only returned when you go to:
http://[somesite].com/[module_controller]
Can this be achieved? If so, how?
Thanks for your assistance.
[Update - Code Solution]
///>MyExtension.php
class MyExtension extends Extension{
public function getMyDataObjectList(){
return 'object list goes here!';
}
}//class
///>[Module] => _config.php
Object::add_extension('Page_Controller', 'MyExtension');
And as always, I do a (/dev/build?flush=1) just in case.
Thanks to: 'simon_w'
Yes, this is relatively straightforward. Simply, create an Extension subclass with your methods in them and then add that to Page_Controller. An Extension subclass is almost exactly the same as a DataExtension, they're just for classes other than DataObjects.
I am trying to use paperclip 3.5.1 with devise 3.1.0 in a Rails 4 application.
I wanted to be able to add an avatar for my User devise model, so I generated the required fields but I have problem in the showing and saving the picture.
I tried the solution given here but when I try to load a url now I get for every controller that I have the following error. It even appears for the RegistrationController.
undefined method `devise_controllers?' for #<__Some__Controller:_____>
Why does this happen and how can I solve it? I couldn't find any solutions online and since it is my first rails application I'm not so familiar with it yet.
This is just a typo: the name of the helper is :devise_controller?, notice the extra "s" you have there: rubydoc reference
can anyone tell me how to call only blocktopmenu module in prestashop...if i use displayTop hook it calls various other modules along with it..but i only want to call blocktopmenu..is it possible to create an object of Blocktopmenu class and access the hookDisplayTop() of that class..so that i can avoid other modules...i tried but its not working
when i try to implement this
Call Module in tpl file in prestashop
it shows "This module cannot be transplanted to this hook."
When you call Hook::exec() you can specify a module ID in the 3rd parameter.
It would be something like that:
Hook::exec('displayTop', null, Module::getModuleIdByName('blocktopmenu'));
Regards,
Never touch the FrontController.
You have to create a new hook, then attach your module to this hook.
After that, you can call Hook::exec('your_hook').
I am using a custom layout in Yii. Everything works great in the web part of the app. Then I tried to run the console part of the app to run a job and it says:
exception 'CException' with message 'Property "CConsoleApplication.layout" is not defined.' in /pathToFramework/base/CComponent.php:173
If I revert to the default layout in config/main.php it works again. I can't find any documentation on how to specify the layout only for the console application. I know I can fix it but don't want to get hacky. Does anyone have a clue about the correct wat to go about this? Thanks.
Generally you don't need to specify a layout in your config, but rather do that within your controllers if you're overriding things. That's probably why your CWebApplication can handle things (you're giving it a layout property in your config), but your CConsoleApplication doesn't allow for that property to be set.
Seems like your options are:
Specify your layout property in each controller (any reason you couldn't just use the default views/layouts/main.php?)
Specify your layout property in a config file that is only used for your CWebApplication system instead of your CConsoleApplication
Override your layout property in a config file specific to your CConsoleApplication
Any of the above should work.