Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Доступ к методам модели из кастомного скрипта


Recommended Posts

Привет!
Пишу в лоб импорт товаров через кастомный скрипт, который просто лежит в корне. Хочу у модели продукта дернуть метод addProduct и скормить в него массив значений.
Скрипт мой лежит тупо в корне, никак не получается достучаться до модели. Гуглил, ответы со стаковерфлоу не работают :)
Ругается, что пытаюсь вызвать функцию на NULL
Вот код

require_once('config.php');
require_once('system/startup.php');

$registry = new Registry();
$event = new Event($registry);
$registry->set('event', $event);
$loader = new Loader($registry);
$registry->set('load', $loader);
$pmodel = $loader->model('catalog/product');
echo var_dump($pmodel->getProduct(55));

 

Link to comment
Share on other sites


9 minutes ago, MikeTheRaven said:

$application_config = 'catalog';

require_once('config.php');
require_once(DIR_SYSTEM . 'startup.php');
require_once(DIR_SYSTEM . 'framework.php');

$loader->model('catalog/product');

$product = $registry->get('model_catalog_product')->getProduct(55);

var_dump($product);

 

 

Это вместо всего моего кода? Меня тогда перекидывает на главную страницу магазина 

Link to comment
Share on other sites


1 hour ago, MikeTheRaven said:

Скопируйте файл /system/framework.php, отключите в нём вывод контента


// Output
$response->setCompression($config->get('config_compression'));
$response->output();

и используйте этот файл, вместо стандартного.

Убрал, всё равно перекидывает на главную. Что использую правильный framework.php проверял - если в самом начале делал какой-нибудь вывод, то падало с ошибкой, что не может инициализировать сессию

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.