Search the Community
Showing results for tags 'objectmodel.php'.
-
Hello everyone, I've an issue with my module. I'm using the Object Model associated with an Admin Controller to add custom “ranges” for the products that are multilingual and multishop. I've followed the tutorial on the devdocs of PrestaShop 1.7 but everything I've tried got me the same result : The data are inserting in all the table but not the main one (like in the attached picture). Here is my Gamme model : class Gamme extends ObjectModel { public $id; /** * @var int $id_product_gamme ID of the gamme */ public $id_product_gamme; /** * @var string $name Name of the gamme */ public $name; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'product_gamme', 'primary' => 'id_product_gamme', 'multilang' => true, 'multilang_shop' => true, 'fields' => array( // Lang field 'name' => array( 'type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255 ), ), ); //Write the add method here, it add a gamme to the database and return the id of the gamme added public function add($autodate = true, $null_values = false) { if (parent::add($autodate, $null_values)) { $this->id_product_gamme = (int)$this->id; return true; } return false; } /* * Get a list of gamme objects * * @param int $id_lang ID of the language to get the gamme names in (default: current language) * @param bool $active Whether to only retrieve active gamme (default: true) * * @return array Array of Gamme objects */ public static function getGammes($id_lang = false, $id_shop = false) { $gammes = array(); $sql = 'SELECT g.`id_product_gamme` FROM `' . _DB_PREFIX_ . 'product_gamme` g ' . Shop::addSqlAssociation('product_gamme', 'g') . ' LEFT JOIN `' . _DB_PREFIX_ . 'product_gamme_lang` gl ON (g.`id_product_gamme` = gl.`id_product_gamme`' . Shop::addSqlRestrictionOnLang('gl') . ') LEFT JOIN `' . _DB_PREFIX_ . 'product_gamme_shop` gs ON (g.`id_product_gamme` = gs.`id_product_gamme`' . Shop::addSqlRestrictionOnLang('gs') . ') WHERE 1 ' . ($id_lang ? 'AND gl.`id_lang` = ' . (int)$id_lang : '') . ' ' . ($id_shop ? 'AND gs.`id_shop` = ' . (int)$id_shop : '') . ' ORDER BY g.`id_product_gamme` ASC'; $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); foreach ($results as $row) { $gamme = new Gamme($row['id_product_gamme'], $id_lang); $gammes[] = $gamme; } return $gammes; } } The controller : require_once _PS_MODULE_DIR_ . 'elementfive/classes/Gamme.php'; class AdminElementFiveGammeController extends ModuleAdminController { public function __construct() { Shop::addTableAssociation('product_gamme', ['type' => 'shop']); Shop::addTableAssociation('product_gamme_lang', ['type' => 'fk_shop']); $this->bootstrap = true; $this->table = Gamme::$definition['table']; $this->className = 'Gamme'; $this->lang = true; $this->identifier = Gamme::$definition['primary']; $this->default_form_language = (int) Configuration::get('PS_LANG_DEFAULT'); $this->allow_employee_form_lang = (int) Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG'); $this->context = Context::getContext(); $this->fields_list = array( 'id_product_gamme' => array( 'title' => Context::getContext()->getTranslator()->trans('ID'), 'align' => 'center', 'class' => 'fixed-width-xs', ), 'name' => array( 'title' => Context::getContext()->getTranslator()->trans('Name'), 'filter_key' => 'b!name', 'lang' => true, ), ); $this->bulk_actions = array( 'delete' => array( 'text' => Context::getContext()->getTranslator()->trans('Delete selected'), 'confirm' => Context::getContext()->getTranslator()->trans('Would you like to delete the selected items?'), ) ); parent::__construct(); } public function renderForm() { $this->fields_form = [ 'legend' => [ 'title' => $this->l('Gamme'), 'icon' => 'icon-cogs' ], 'input' => [ [ 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'lang' => true, 'required' => true, 'col' => 4, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'empty_message' => $this->l('This field is required.'), ] ], 'submit' => [ 'title' => $this->l('Save'), 'name' => 'submitAdd' . $this->table, ] ]; if (Shop::isFeatureActive()) { $this->fields_form['input'][] = [ 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'id_shop', ]; } return parent::renderForm(); } } Thanks for helping me, let me know if I have to add more information.
-
prestashop 1.7.6.5, but I got the same error 500 with version 1.7.6.2 The order process in front office works with no problems. If I try to create a new order from back office, when I save it I get error 500. The same error with or without disabling Overrides and non prestashop modules. Default Currency is Euro. Anyone have some idea? The following is the result of the Debug: [PrestaShopException] La proprietà Cart->id_currency è vuota. (Property Cart->id_currency is empty) at line 1003 in file classes/ObjectModel.php 998. } 999. 1000. $message = $this->validateField($field, $this->$field); 1001. if ($message !== true) { 1002. if ($die) { 1003. throw new PrestaShopException($message); 1004. } 1005. 1006. return $error_return ? $message : false; 1007. } 1008. } ObjectModelCore->validateFields - [line 292 - classes/ObjectModel.php] ObjectModelCore->getFields - [line 737 - classes/ObjectModel.php] ObjectModelCore->update - [line 295 - classes/Cart.php] - [1 Arguments] CartCore->update - [line 330 - modules/shippingaddress/shippingaddress.php] ShippingAddress->initializeShippingAddress - [line 186 - modules/shippingaddress/shippingaddress.php] ShippingAddress->hookActionGetIDZoneByAddressID - [line 970 - classes/Hook.php] - [1 Arguments] HookCore::coreCallHook - [line 355 - classes/Hook.php] - [3 Arguments]
- 3 replies
-
- error 500
- objectmodel.php
-
(and 3 more)
Tagged with:
-
Bonjour, Après avoir tenté de migrer de version PHP 5.6 vers 7.0, le site est devenu inaccessible (erreur 500). J'ai tenté de supprimer le fichier www/cache/class_index.php mais cela ne solutionne pas le problème. Une idée? En mode debug "true": Fatal error: Interface 'Core_Foundation_Database_EntityInterface' not found in classes/ObjectModel.php on line 27 ou Warning: scandir(/home/novoflexik/www/Adapter/): failed to open dir: No such file or directory in www/classes/PrestaShopAutoload.php on line 184 Warning: scandir(): (errno 2): No such file or directory in www/classes/PrestaShopAutoload.php on line 184 Warning: Invalid argument supplied for foreach() in www/classes/PrestaShopAutoload.php on line 184 Warning: scandir(/home/novoflexik/www/Core/): failed to open dir: No such file or directory in www/classes/PrestaShopAutoload.php on line 184 Warning: scandir(): (errno 2): No such file or directory in www/classes/PrestaShopAutoload.php on line 184 Warning: Invalid argument supplied for foreach() in www/classes/PrestaShopAutoload.php on line 184 Fatal error: Interface 'Core_Foundation_Database_EntityInterface' not found in www/classes/ObjectModel.php on line 27
- 5 replies
-
- erreur 500
- php
-
(and 2 more)
Tagged with:
-
Prestashop 7.3.2 Ineens, vanuit het niets, is mijn index-pagina op http://www.glasinlood-delden.nl/webshop2 nog maar half zichtbaar. Als ik in de module "aangepaste tekstblokken" kijk, is alles prima zichtbaar, maar als ik opsla zie ik de foutmeldingen zoals die in de bijlage is te zien. Kan iemand mij aub helpen??
-
Buen dia comunidad y equipo de PrestaShop Como veran estoy teniendo incovenientes al instalar mercado pago en mi tienda de prestashop, el cual al momento de instalar emite el siguiente error. [PrestaShopException] Property OrderState->logable is not valid at line 917 in file classes/ObjectModel.php 912. } 913. 914. $message = $this->validateField($field, $this->$field); 915. if ($message !== true) { 916. if ($die) { 917. throw new PrestaShopException($message); 918. } 919. return $error_return ? $message : false; 920. } 921. } 922. ObjectModelCore->validateFields - [line 246 - classes/ObjectModel.php] ObjectModelCore->getFields - [line 487 - classes/ObjectModel.php] ObjectModelCore->add - [line 282 - modules/mercadopago/mercadopago.php] MercadoPago->createStates - [line 332 - modules/mercadopago/mercadopago.php] MercadoPago->install - [line 868 - controllers/admin/AdminModulesController.php] AdminModulesControllerCore->postProcessCallback - [line 1117 - controllers/admin/AdminModulesController.php] AdminModulesControllerCore->postProcess - [line 178 - classes/controller/Controller.php] ControllerCore->run - [line 367 - classes/Dispatcher.php] DispatcherCore->dispatch - [line 58 - admin/index.php] Al actualizar la pagina el modulo se instala, pero de forma incompleta, ya que no aparece en metodos de pago. Espero su pronta colaboracion respeto a este problema, Cordialmente Cristian S Vargas G
-
- error
- mercado pago
-
(and 1 more)
Tagged with:
-
Acabo de migrar la web de servidor y me aparece el siguiente error al querer introducir un producto en la tienda. Utilizo la versión 1.5.2.0 sobre PHP 5.2.17, con límite de memoria 1024M y Tiempo Máximo de ejecución 300, Versión de MySQL: 5.5.44-MariaDB-1ubuntu0.14.04.1 y Motor MySQL: InnoDB. Catchable fatal error: Argument 2 passed to ObjectModelCore::hydrateCollection() must be an array, boolean given, called in /var/www/vhosts/web.com/httpdocs/classes/Collection.php on line 344 and defined in /var/www/vhosts/web.com/httpdocs/classes/ObjectModel.php on line 1364 Línea 304 del archivo Collection.php: $this->results = ObjectModel::hydrateCollection($this->classname, $this->results, $this->id_lang); Línea 1364 del archivo ObjectModel.php: public static function hydrateCollection($class, array $datas, $id_lang = null) { if (!class_exists($class)) throw new PrestaShopException("Class '$class' not found"); $collection = array(); $rows = array(); if ($datas) { $definition = ObjectModel::getDefinition($class); if (!array_key_exists($definition['primary'], $datas[0])) throw new PrestaShopException("Identifier '{$definition['primary']}' not found for class '$class'"); foreach ($datas as $row) { // Get object common properties $id = $row[$definition['primary']]; if (!isset($rows[$id])) $rows[$id] = $row; // Get object lang properties if (isset($row['id_lang']) && !$id_lang) foreach ($definition['fields'] as $field => $data) if (!empty($data['lang'])) { if (!is_array($rows[$id][$field])) $rows[$id][$field] = array(); $rows[$id][$field][$row['id_lang']] = $row[$field]; } } } // Hydrate objects foreach ($rows as $row) { $obj = new $class; $obj->hydrate($row, $id_lang); $collection[] = $obj; } return $collection; } ¿A alguien le sucedió esto mismo que me pueda ayudar?
-
- Error
- Collection.php
-
(and 3 more)
Tagged with:
-
Давно обновил версию на 1.5.6.1. и больше не могу редактировать странички, выскакивает следующее: [PrestaShopException]Property CMS->content is not valid at line 878 in file classes/ObjectModel.php 872. 873. $message = $this->validateField($field, $value, $id_lang); 874. if ($message !== true) 875. { 876. if ($die) 877. throw new PrestaShopException($message); 878. return $error_return ? $message : false; 879. } 880. } 881. } 882. ObjectModelCore->validateFieldsLang - [line 296 - classes/ObjectModel.php] - [0 Argument] ObjectModelCore->getFieldsLang - [line 634 - classes/ObjectModel.php] - [0 Argument] ObjectModelCore->update - [line 75 - classes/CMS.php] - [1 Arguments] CMSCore->update - [line 334 - controllers/admin/AdminCmsController.php] - [0 Argument] AdminCmsControllerCore->postProcess - [line 121 - controllers/admin/AdminCmsContentController.php] - [0 Argument] AdminCmsContentControllerCore->postProcess - [line 158 - classes/controller/Controller.php] - [0 Argument] ControllerCore->run - [line 348 - classes/Dispatcher.php] - [0 Argument] Что делать - help
- 4 replies
-
- prestashop 1.5.6.1.
- objectmodel.php
- (and 3 more)