Magento
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2102
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2435
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2451
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2456
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2461
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2467
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2479
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2496
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2497
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2498
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2499
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2517
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2518
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2519
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2520
Deprecated: Non-static method MagicWord::get() should not be called statically, assuming $this from incompatible context in /home/clients/newman_ftp0/domains/wiki.pws.ru/html/includes/Parser.php on line 2550
Материал из Newman's WiKi.
| Версия 06:42, 16 января 2013 WikiSysop (Обсуждение | вклад) (→В разделы в админке) ← К предыдущему изменению |
Текущая версия WikiSysop (Обсуждение | вклад) (→Определить наличие товара (в стоке или нет)) |
||
| Строка 16: | Строка 16: | ||
| === Разделы в админке === | === Разделы в админке === | ||
| Бывает что при разработке разделов в админке, либо при установке модуля не получается перейти к настройкам параметров и в результате система возвращает ошибку 404 - Not found. Такое чаще всего происходит при неверно настроенных права доступа. Особенно если в лог файлах нет сообщение об ошибка и очистка кеша не помогает. В этом случае надо проверить права доступа. А также НУЖНО выйти и снова зайти в админку. Судя по всему права доступа к модулям инициализируются при логине и больше не обновляются, до конца сессии работы с админкой. | Бывает что при разработке разделов в админке, либо при установке модуля не получается перейти к настройкам параметров и в результате система возвращает ошибку 404 - Not found. Такое чаще всего происходит при неверно настроенных права доступа. Особенно если в лог файлах нет сообщение об ошибка и очистка кеша не помогает. В этом случае надо проверить права доступа. А также НУЖНО выйти и снова зайти в админку. Судя по всему права доступа к модулям инициализируются при логине и больше не обновляются, до конца сессии работы с админкой. | ||
| + | === Загрузка товара по данным === | ||
| + | Иногда нужно загрузить товар не только по его id в таблице товаров, но и просто по каким-том данным. Например по SKU. | ||
| + | Это можно сделать следующим образом | ||
| + | <pre> | ||
| + | $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku); | ||
| + | </pre> | ||
| + | === Вывод цены товара с указанием валюты === | ||
| + | <pre> | ||
| + | echo Mage::helper('core')->currency($product->getFinalPrice(),true,false); | ||
| + | </pre> | ||
| + | === Определить наличие товара (в стоке или нет) === | ||
| + | <pre> | ||
| + | $stockItem = $product->getStockItem(); | ||
| + | if ($stockItem->getIsInStock()) { | ||
| + | error_log("In stock"); | ||
| + | } else { | ||
| + | error_log("Out of stock"); | ||
| + | } | ||
| + | </pre> | ||
| + | === Перенос на другой сервер === | ||
| + | Magento хранит в MySQL базовый адрес сервера. И при переносе магазина на другой сервер или другой домен посетителя будет по прежнему перебрасывать на адрес, который хранится в базе. Исправить это можно либо через phpMyAdmin либо вот таким скриптом | ||
| + | <pre> | ||
| + | UPDATE core_config_data | ||
| + | SET value='http://newdoamin.tld/' | ||
| + | WHERE path = 'web/unsecure/base_url' OR path='web/secure/base_url'; | ||
| + | </pre> | ||
| + | И желательно почистить кеш - удалить содержимое папки '''var''' в корне магазина | ||
| + | [[Категория:Опыт]] | ||
| + | [[Категория:Интернет магазин]] | ||
| + | [[Категория:Хитрости]] | ||
Текущая версия
Magento система e-commerce. Движок интернет магазина.
Содержание |
Хитрости
Вывод отладочной информации
Структуры данных в Magento слишком сложны и при использовании стандартного подхода отладки с использованием print_r приводят к зависанию системы - как правило все объекты связанны друг с другом и функция пытается вывести практически всю информацию.
Частично может упростить задачу использования метода debug(), который может быть почти у каждого элемента. Т.е. вместо
print_r($item);
лучше писать
print_r($item->debug());
Разделы в админке
Бывает что при разработке разделов в админке, либо при установке модуля не получается перейти к настройкам параметров и в результате система возвращает ошибку 404 - Not found. Такое чаще всего происходит при неверно настроенных права доступа. Особенно если в лог файлах нет сообщение об ошибка и очистка кеша не помогает. В этом случае надо проверить права доступа. А также НУЖНО выйти и снова зайти в админку. Судя по всему права доступа к модулям инициализируются при логине и больше не обновляются, до конца сессии работы с админкой.
Загрузка товара по данным
Иногда нужно загрузить товар не только по его id в таблице товаров, но и просто по каким-том данным. Например по SKU. Это можно сделать следующим образом
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
Вывод цены товара с указанием валюты
echo Mage::helper('core')->currency($product->getFinalPrice(),true,false);
Определить наличие товара (в стоке или нет)
$stockItem = $product->getStockItem();
if ($stockItem->getIsInStock()) {
error_log("In stock");
} else {
error_log("Out of stock");
}
Перенос на другой сервер
Magento хранит в MySQL базовый адрес сервера. И при переносе магазина на другой сервер или другой домен посетителя будет по прежнему перебрасывать на адрес, который хранится в базе. Исправить это можно либо через phpMyAdmin либо вот таким скриптом
UPDATE core_config_data SET value='http://newdoamin.tld/' WHERE path = 'web/unsecure/base_url' OR path='web/secure/base_url';
И желательно почистить кеш - удалить содержимое папки var в корне магазина