After migrating from Magento Professional to Magento Community, I have encountered an issue when attempting to run the "Apply Rules" function inside of Promotions >> Catalog Price Rules.
The exact message I receive is as follows:
"Unable to apply rules. Invalid website code requested: Array"
Has anyone seen this before? I can't seem to find /any/ information on the error.
Thanks for any help!
In Model App.php
app/code/core/Mage/Core/Model/App.php
public function getWebsite($id=null)
{
if (is_null($id)) {
$id = $this->getStore()->getWebsiteId();
} elseif ($id instanceof Mage_Core_Model_Website) {
return $id;
} elseif ($id === true) {
return $this->_website;
}
if (empty($this->_websites[$id])) {
$website = Mage::getModel('core/website');
if (is_numeric($id)) {
$website->load($id);
if (!$website->hasWebsiteId()) {
throw Mage::exception('Mage_Core', 'Invalid website id requested.');
}
} elseif (is_string($id)) {
$websiteConfig = $this->_config->getNode('websites/'.$id);
if (!$websiteConfig) {
throw Mage::exception('Mage_Core', 'Invalid website code requested: '.$id);
}
$website->loadConfig($id);
}
$this->_websites[$website->getWebsiteId()] = $website;
$this->_websites[$website->getCode()] = $website;
}
return $this->_websites[$id];
}
if you see the line that throw exception Invalid website code requested :$id
This is the exception happen in your case and its because the Price rule assigned to website not exist or wrong id or something related to this.
Try to delete the rule and adding it again.
Could you please check the patches which you migrated to magento community. I hope someting miss coded. Some kind of Array printed during executing code.
https://chat.stackoverflow.com/transcript/message/9332922#9332922
Thanks.
I had the same problem when migrated fro 1.5.1.0 to 1.7.0.2 Magento CE. The problem is with the columns "website_ids" and "customer_group_ids" of the catalogrule table. These columns don't exist in 1.7.0.2 database, but if you try to remove them from a migrated Magento store you will not be able to save any rule. The solution I found is that I assigned NULL value directly in the database for these two columns and afterwards the Apply Rule button worked. However, you need to repeat that job if you save again the rule.
Related
I've created a custom page devis and its controller in Prestashop 1.6, but I'm unable to display any columns.
Controller :
class DevisController extends FrontController
{
public $php_self = 'devis';
public $display_column_left = true;
...
}
In Theme configuration, my 'Devis' page appears and the left column is checked :
The "display or not" logic happens in FrontController.php's constructor :
if (isset($this->php_self) && is_object(Context::getContext()->theme)) {
$columns = Context::getContext()->theme->hasColumns($this->php_self);
// Don't use theme tables if not configured in DB
if ($columns) {
$this->display_column_left = $columns['left_column']; // FALSE : why ?
$this->display_column_right = $columns['right_column'];
}
}
I can force the column to display by doing $this->display_column_left = true but it's obviously not the way to do it.
Does someone know why $columns['left_column'] is false ?
Sh*t...
As mentionned by #julien-lachal, the issue was shop-level related.
That means I was browsing the dashboard as "All the shops".
By choosing the desired shop, the left column in theme settings was actually disabled.
Big problems simple fixes...
I want to hide the COMPANY field from the Customer Account dashboard (don't ask why).
I found that the address is generated here:
/app/code/core/Mage/Customer/Model/Customer.php
I created a local version to override the core file and then changed public function getAddressesCollection() to the following:
public function getAddressesCollection()
{
if ($this->_addressesCollection === null) {
$this->_addressesCollection = $this->getAddressCollection()
->setCustomerFilter($this)
//->addAttributeToSelect('*')
->addAttributeToSelect('prefix')
->addAttributeToSelect('firstname')
->addAttributeToSelect('middlename')
->addAttributeToSelect('lastname')
->addAttributeToSelect('suffix')
->addAttributeToSelect('street')
->addAttributeToSelect('city')
->addAttributeToSelect('country_id')
->addAttributeToSelect('region')
->addAttributeToSelect('region_id')
->addAttributeToSelect('postcode')
->addAttributeToSelect('telephone')
->addAttributeToSelect('fax')
->addAttributeToSelect('vat_id')
->addAttributeToSelect('vat_is_valid')
->addAttributeToSelect('vat_request_id')
->addAttributeToSelect('vat_request_date')
->addAttributeToSelect('vat_request_success');
foreach ($this->_addressesCollection as $address) {
$address->setCustomer($this);
}
}
return $this->_addressesCollection;
}
I commented out the addAttributeToSelect('*') and replaced it with every customer_address attribute except for COMPANY.
Is this acceptable? It works but I want to know if it will have any obvious negative impact.
Thanks
I apologize in advance for my ignorance of CodeIgniter and the MVC system.
I'm helping a family member with their business website and up until now I've been able to complete most of the required changes just by using logic but now I've hit a dead end. I don't plan to continue supporting them as I'm obviously no CodeIgniter expert. But I'm hoping to leave the website at least functional, so that they can start using it.
I simply want to create a new "page" within the website but it seems impossible. If I can achieve this I think I can figure everything else out on my own.
For example I currently have a "page" for Cancelled Jobs. It the navigation HTML it is linked to like this:
http://localhost/admin/modules/cancelled_jobs
and has a corresponding file here: admin/application/controllers/cancelled_jobs.php
which contains this php code:
class Cancelled_jobs extends CIID_Controller {
public function __construct()
{
parent::__construct();
$this->set_table('job', 'Cancelled Job', 'Cancelled Jobs');
$this->allow_delete = false;
$this->allow_cancel = false;
$this->allow_edit = false;
$this->allow_reactivate = true;
$this->allow_add = false;
$this->overview
->add_item('Job No', 'active', 'job_id')
->add_item('Client', 'active|relationship', 'client.name')
->add_item('Name', 'active', 'name')
->add_item('Status', 'active|relationship', 'job_status.name')
->add_item('Assignee', 'active|relationship', 'team_member.name')
->add_item('Scheduled Date', 'active', 'scheduled_date')
->where("job.cancel_job = '1'")
->order_by('job.created_date DESC');
$this->init();
}
}
I would like to create a new "page" called Closed Jobs.
I've tried copying admin/application/controllers/cancelled_jobs.php and renaming it closed_jobs.php and changing the first line of code to read:
class Closed_jobs extends CIID_Controller {
I then add a link in the navigation HTML:
http://localhost/admin/modules/closed_jobs
However, when clicked, this only results in a "404 Page Not Found" error.
Can anyone point out what I'm missing in the process of creating a new page?
Generally, CodeIgniter URLstructure is:
sitename.com/controller_name/function_name/parameter_1/parameter_2/parameter_3/
You can add as many parameters as you want.
To access
modules/closed_jobs:
Add a new function in the controller modules
function closed_jobs() {
$this->load->view('closed_jobs');
}
And create a view closed_jobs.php
in application/views
Repeat the same for cancelled_jobs
I'm creating a recommendation controller using PHP Yii framework, using a heuristic concept. My recommendation will only work if the user or other user with the same course have made a booking. But right now if my bookings is equal to null it is showing an error message like below:
Error 500 Invalid argument supplied for foreach()
Therefore I have made a condition where I created my own message:
We are sorry currently there are no recommendation of books at this moment
and it is working. Unfortunately, it also shows together with the error message. I just want to show only my own message. Below is my code:
//recommendation - use heuristic concept, more accurate result as more people same course recommendation
public function actionRecommendation() {
$user = User::model()->findByPk(Yii::app()->user->id);
//get course mates
$courseMates = User::model()->findAllByAttributes(array('course_id' => $user->course_id));
$popularity = array();
if($bookings==null){Yii::app()->user->setFlash('success', 'We are sorry currently there are no recommendation of books at this moment'); }
foreach ($courseMates as $courseMate) {
//identify all bookings made by user
$bookings = Booking::model()->findAllByAttributes(array('user_id' => $courseMate->id));
foreach ($bookings as $booking) {
//add hit into array as per book
$popularity[$booking->book_id] = (isset($popularity[$booking->book_id])) ? $popularity[$booking->book_id] + 1 : 1;
}
}
//sort according to popular count
arsort($popularity, SORT_NUMERIC);
$display = 10;
foreach ($popularity as $bookId => $popular) {
//if display is 0, break the foreach, only display up 10
if ($display == 0) {
break;
}
//create book object array
$books[] = Book::model()->findByPk($bookId);
//reduce book count
$display--;
}
$this->render('recommendation',array(
'books'=>$books,
));
}()
How can I modify it so it displays just the custom error message?
For Input Fields
*In your Model*
array('gender','required','message'=>'Please select gender.'),
Or can call Function too.
array('gender', 'ownFunction'),
public function ownFunction() {
{
if (empty($this->gender))
$this->addError("gender", 'Please select gender.');
}
}
Using this you can display custom error message on input fields
For Error Page
for Custom message in Error Page .
In your Controller
if(Your Condition)
{
//Show Error form.
throw new CHttpException(500,'We are sorry currently there are no recommendation of books at this moment. ');
}
else
{
/* rest of code goes Here */
}
Hope this Helps You
Helllo,
Recently I upgraded to 6.2 GA from 6.1.4 via the upgrade patch.
Even since then I'm unable to create anything that has direct relation with Date & Time, namely, Call Logs, Meetings and Tasks.
When I do the same using a subpanel, the entry simply vanishes and is NEVER created.
When I try from one of the respective modules under Activities, I get a HTTP 500 error upon submission.
The Apache error log reveals the following:
PHP Catchable fatal error: Argument 1 passed to TimeDate::_getUserTZ() must be
an instance of User, boolean given, called in /home/crm/include/TimeDate.php on
line 849 and defined in /home/crm/include/TimeDate.php on line 259, referer:
http://mysite/index.php?module=Leads&offset=1&stamp=1307694072083825200&return_module=Leads&action=DetailView&record=xxxxxxxxxxxx
Unfortunately, this has happened to a production server and I noticed this problem only too late.
How can I fix this? Seeking your help urgently.
Thanks,
m^e
UPDATE 1
I've managed to apply a temporary patch to this and got it working...
Line 849 of TimeDate.php is part of a function that looks like:
function to_display_date_time($date, $meridiem = true, $convert_tz = true, $user = null)
{
return $this->_convert($date,
self::DB_DATETIME_FORMAT, self::$gmtTimezone, $this->get_date_time_format($user),
$convert_tz ? $this->_getUserTZ($user) : self::$gmtTimezone, true);
}
This function is in turn calling another one _getUserTZ() to which it is supposed to pass a variable of the type User. Instead it is passing null.
I used a snippet to check for empty $user and assign a value to it if needed. The code is part of another function named _getUser() found in this same file....
protected function _getUser(User $user = null)
{
if (empty($user)) {
$user = $this->user;
}
if (empty($user)) {
$user = $GLOBALS['current_user'];
}
return $user;
}
I borrowed the code from this function and pasted it inside to_display_date_time(), making it look like:
function to_display_date_time($date, $meridiem = true, $convert_tz = true, $user = null)
{
if (empty($user)) {
$user = $this->user;
}
if (empty($user)) {
$user = $GLOBALS['current_user'];
}
return $this->_convert($date,
self::DB_DATETIME_FORMAT, self::$gmtTimezone, $this->get_date_time_format($user),
$convert_tz ? $this->_getUserTZ($user) : self::$gmtTimezone, true);
}
Now Calls / Meetings are working again.. but I still wonder what's the actual fix to this issue. My way should prove to be a quick fix for anyone who needs to rectify this in a hurry.
If anyone can get to the root of the problem and a more elegant fix, I'm willing to offer a bounty.
Cheers,
m^e