Php Prestashop 1.6核心控制器超控
我目前正试图覆盖PrestaShop 1.6.1中的核心控制器保护功能。控制器是AddressController.php 覆盖控制器看起来像:Php Prestashop 1.6核心控制器超控,php,prestashop-1.6,Php,Prestashop 1.6,我目前正试图覆盖PrestaShop 1.6.1中的核心控制器保护功能。控制器是AddressController.php 覆盖控制器看起来像: class AddressController extends AddressControllerCore { /** * Assign template vars related to countries display */ protected function assignCountries() {
class AddressController extends AddressControllerCore
{
/**
* Assign template vars related to countries display
*/
protected function assignCountries()
{
$this->id_country = (int)Tools::getCountry($this->_address);
// Generate countries list
if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES')) {
$countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
} else {
$countries = Country::getCountries($this->context->language->id, true);
}
// @todo use helper
$list = '';
$product_by_country = Configuration::get('TOOLPRODUCTCOUNTRY_PRICE');
foreach ($countries as $country) {
if($product_by_country==1){
if (isset(Context::getContext()->cookie->productcountry_delivery)) {
$selected = ((int)$country['id_country'] === Context::getContext()->cookie->productcountry_delivery) ? ' selected="selected"' : '';
} else {
$selected = ((int)$country['id_country'] === $this->id_country) ? ' selected="selected"' : '';
}
} else {
$selected = ((int)$country['id_country'] === $this->id_country) ? ' selected="selected"' : '';
}
$list .= '<option value="'.(int)$country['id_country'].'"'.$selected.'>'.htmlentities($country['name'], ENT_COMPAT, 'UTF-8').'</option>';
}
// Assign vars
$this->context->smarty->assign(array(
'countries_list' => $list,
'countries' => $countries,
'sl_country' => (int)$this->id_country,
));
}
}
类AddressController扩展AddressControllerCore
{
/**
*分配与国家/地区显示相关的模板变量
*/
受保护的功能分配国家()
{
$this->id\u country=(int)Tools::getCountry($this->\u地址);
//生成国家/地区列表
if(配置::get('PS\u RESTRICT\u DELIVERED\u COUNTRIES')){
$countries=Carrier::getDeliveredCountries($this->context->language->id,true,true);
}否则{
$countries=Country::getCountries($this->context->language->id,true);
}
//@todo-use-helper
$list='';
$product_by_country=配置::get('TOOLPRODUCTCOUNTRY_PRICE');
foreach($国家作为$国家){
如果($product\u by\u country==1){
if(isset(Context::getContext()->cookie->productcountry_delivery)){
$selected=((int)$country['id\u country']==Context::getContext()->cookie->productcountry\u delivery)?'selected=“selected”:'';
}否则{
$selected=((int)$country['id\u country']===$this->id\u country)?'selected=“selected”:'';
}
}否则{
$selected=((int)$country['id\u country']===$this->id\u country)?'selected=“selected”:'';
}
$list.=''.htmlentities($country['name'],ENT_COMPAT,'UTF-8');
}
//分配变量
$this->context->smarty->assign(数组)(
“国家/地区列表”=>美元列表,
“国家”=>$countries,
'sl_country'=>(int)$this->id_country,
));
}
}
基本上,我希望在签出步骤中将另一个国家显示为默认国家,而不是在PrestaShop BO中为$(“#id_country”)
下拉列表选择的国家。在签出过程之前选择所需的国家/地区,并存储为productcountry\u delivery
。
问题是Prestashop没有考虑到这段代码,就好像它不存在一样。
我从缓存文件夹中删除了class_index.php以强制重新编译,但仍然没有成功
有人能帮我弄清楚吗
谢谢大家! 确保将覆盖文件保存在此位置
override/controllers/front/AddressController.php
文件位置正确。问题存在于其他地方。在文件class_index.php中,检查该类是否真的被覆盖,您应该找到一行,上面写着'path'=>'override/controllers/front/AddressController.php',
,如果不是,则是某种PS错误,或者读权限问题可能已经这样做了。该文件已存在并被覆盖。。。