OpenCart can't add or edit product - php

My OpenCart version 1.5.6 and I'm not using vQmod.
So recently I added one custom product field. This tutorial helped me to do that
http://forum.opencart.com/viewtopic.php?f=22&t=36625#p181916
Now, when I'm trying to add a new product to store this error appears:
Fatal error: Call to undefined method ModelCatalogCategory::getAllCategories() in C:\apache\localhost\www\webshop.kg\admin\controller\catalog\product.php on line 1018
If I'm trying to edit already existing product these two errors appear:
Notice: Undefined index: seo_title in C:\apache\localhost\www\webshop.kg\admin\model\catalog\product.php on line 456Notice: Undefined index: seo_h1 in C:\apache\localhost\www\webshop.kg\admin\model\catalog\product.php on line 457
Fatal error: Call to undefined method ModelCatalogCategory::getAllCategories() in C:\apache\localhost\www\webshop.kg\admin\controller\catalog\product.php on line 1018
What possible reason could create such a behavior?
Thank you for your attention.

The problem is within your controller as the model in admin/model/catalog/category.php does not contain a method getAllCategories() (unless you added it there which is not a case because of the fatal error) - it contains only the method getCategories().
Furthermore your Undefined index notices are saying that within your product model (lines 456 and 457) you are relying on the presence of the indexes seo_title and seo_h1 but they are not set.
I do not know the code you have modified in admin/model/catalog/product.php but you should use something like this:
if(isset($data['seo_title'])) { /* do setting of seo title */ } /* else { do not set this } */
if(isset($data['seo_h1'])) { /* do setting of seo h1 */ } /* else { do not set this } */
Maybe posting the method reliable for storing new or updating existing product code would be more helpful...

The model in admin/model/catalog/category.php does not contain a method getAllCategories(). So you need to define it in category model.
public function getAllCateories() {
$query = "WRITE YOUR QUERY";
}

Related

Call to undefined method Mail::setMessageType()

I have a website and it has a member registry (Way of Life). It uses phpmailer which I am not very familiar with. When you enter data and click register, it returns this:
Fatal error: Call to undefined method Mail::setMessageType() in
/home/u536535282/public_html/classes/phpmailer/phpmailer.php on line
989
The lines that this is referring to are shown below:
$this->error_count = 0; // reset errors
$this->setMessageType();
if (!$this->AllowEmpty and empty($this->Body)) {
throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
}
If someone colud tell me what i need to change, I would appreciate it, as it would get my site going again

Magento getConfigurableAttributesAsArray causes fatal error

I am trying to write a script that creates configurable products. Ive been using this as a guide: http://inchoo.net/magento/programmatically-create-a-configurable-magento-product/
When I get to this line:
$configurableAttributesData = $configProduct->getTypeInstance()->getConfigurableAttributesAsArray();
The script crashes and kicks out this error:
Fatal error: Call to a member function getId() on a non-object in /home/buyfrom/public_html/app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php on line 283
Following a comment on this page, I changed that line to the following:
$possibleAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
But I am still getting this error. Can anyone suggest how to fix this?
Make sure that attribute set (eg. default) which you are choosing is having at least one configurable attribute (example: 'color' or 'size').

How to load two models in the same controller with CodeIgniter?

I've been searching on Internet and on stackoverflow, but i didn't find a solution, or it wasn't the same problem.
I need to load two models in the same controller, and in the same function. One is "model_membre" and the other "model_annonce". It's the name of the class, the file, and the object.
Individually, they work very good, i can access to properties and methods, but when I'm loading the two models, I can't access to the second, regardless of how I load it (autoload, $this->load->model('model_name'), $this->load->model('model_name', 'object_name')).
I simplified to a "test" controller, to see if it was not another part of my code that made the problem :
public function index()
{
$this->load->model('model_membre', 'membre');
$this->load->model('model_annonce', 'annonce');
$liste = $this->annonce->listerEspeces();
$membre = $this->membre->obtenirMembre(1);
}
I tried to changer the order, and the 2nd loaded never works. I get this message :
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Test::$annonce
Filename: controllers/test.php
Line Number: 15
Fatal error: Call to a member function listerEspeces() on a non-object in /homez.604/animalix/beta/application/controllers/test.php on line 15
Please try the following way...
public function index()
{
$this->load->model(array('membre','annonce'));
$liste = $this->annonce->listerEspeces();
$membre = $this->membre->obtenirMembre(1);
}
The models should extend CI_Model and not CI_Controller! This was the source of the problem.

Magento 1.7.0.2 Fatal error: Call to a member function getInputType() on a non-object

I've just upgraded to Magento 1.7.0.2 and am having two problems that I think are related.
(1) Upon editing or adding a product, I get the following message:
Fatal error: Call to a member function getInputType() on a non-object in /home/.../public_html/app/code/core/Mage/Catalog/Model/Product.php on line 995
I have the Developer Debug profiler turned on and it gives me this additional information:
{{{Images}}{{Images}}{{Images}}{{Mage_Catalog}}}
{{{Image type and information need to be specified for each store view.}}{{Image type and information need to be specified for each store view.}}{{Image type and information need to be specified for each store view.}}{{Mage_Catalog}}}
In the product.php referenced in the fatal error message, the code around line 995 is as follows:
** Media API
*/
/**
* Retrive attributes for media gallery
*
* #return array
*/
public function getMediaAttributes()
{
if (!$this->hasMediaAttributes()) {
$mediaAttributes = array();
foreach ($this->getAttributes() as $attribute) {
if($attribute->getFrontend()->getInputType() == 'media_image') {
$mediaAttributes[$attribute->getAttributeCode()] = $attribute;
}
}
$this->setMediaAttributes($mediaAttributes);
}
return $this->getData('media_attributes');
}
The catalog appears fine; sales appears fine; I've reindexed and emptied caches (multiple times). I don't have any extensions (yet); I have installed a theme but have set it as default in one store and have the same problem. I have a multi-store installation with the addon domain method and all of the stores are exhibiting the same problems.
(2) The other problem I have is that on the frontend, all product pages result in a 404 error. (Catalog, cms and even searches are ok - it looks to be just the product pages.)
I'm more of an 'enthusiast programmer' and am in a bit over my head. I think I'm close but am stuck. Thank you so much for any help or suggestions you might offer.
Cheers!
Penny

Fatal error: Call to a member function getPk() on a non-object (P4A, MySQL)

I'm Not too sure on what this error is, from looking around, it must be something to do with the database declarations. I'm trying to make a drop down box on my Widget, by selecting different fields of the database, different masks will be selected and will allow for different widgets to be made on later pages.
The part of my code where i think the error is, is:
$this->build("p4a_db_source", "login")
->setTable("meetingrooms")
->addJoin("login.meetingrooms",
"login.meetingrooms.MeetingRoom = login.meetingrooms.MeetingRoom",
array('position'=>'Ident'))
->addOrder("position")
->load();
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login')
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);
I know its a similar question to my previous one, but its a different code entirely, but this one should be much easier to fix.
Thanks for the help.
The Stacktrace (Fatal error: Call to a member function getPk() on a non-object in C:\xampp\htdocs\p4a\p4a\objects\widgets\field.php on line 468) isn't indicating the line at which the error is occurring so i'm unsure where exactly the problem is originating from,
The rest of the code (including previous) is:
class main_dashboard_mask extends P4A_Base_Mask
{
public function __construct()
{
parent::__construct();
$this->setTitle("Dashboard");
$this->build('p4a_field','MeetingRooms');
$this->MeetingRooms->setLabel("This is the meeting room label");
$this->build('p4a_button', 'continue')
->setLabel('Continue?')
->implement("onclick", $this, "change");
$this->build('p4a_field','booking')
->setlabel('Viewing?')
->setType('checkbox')
->setValue(true);
$this->booking->label->setTooltip('If you are booking a meeting room, check this box');
$this->build("p4a_db_source", "login")
->setTable("meetingrooms")
->addJoin("login.meetingrooms",
"login.meetingrooms.MeetingRoom = login.meetingrooms.MeetingRoom",
array('position'=>'Ident'))
->addOrder("position")
->load();
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login')
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);
$this->Meetingrooms();
}
private function Meetingrooms()
{
$this->build('P4A_fieldset', 'widgetframe')
->anchor($this->location)
->anchorLeft($this->booking)
->anchorLeft($this->continue)
->setLabel('Meeting Room Bookings');
}
}
I think you are not getting the object. That is why it's giving error of non-object.
Just print the object on which you are calling the method getPk(). If it is valid object then
only call that method.
i got it, sorry i was looking in the right place but didn't see where i was wrong...
where before the code was ->
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login') // <- this is the error(the Pk variable hasn't been set here)
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);
$this->Meetingrooms();
the fix is ->
->setSource($this->login)
Thanks for the assistance =]
Do you have a full stacktrace ? What line of code exactly generates this error ?
Anyway, you have to locate the code where $object->getPk() is called. The error means that you're trying to use a function ->getPk() on an $object that is null ..

Categories