Jump to content

AlexNDR.mac

Members
  • Posts

    107
  • Joined

  • Last visited

Profile Information

  • Location
    Ukraine
  • Activity
    Developer

Recent Profile Visitors

4,132,651 profile views

AlexNDR.mac's Achievements

Newbie

Newbie (1/14)

19

Reputation

1

Community Answers

  1. Преста для использования SVG не подготовлена, поэтому самый простой вариант - if case {if isset("{$base_dir}img/logo.svg")} <img src="{$base_dir}img/logo.svg"> {else} <img src="{$base_dir}img/logo.jpg"> {/if}
  2. If you want to call function by this way - you need to create static function class ClassName { // need instance of class public function TestFunction() { $page = "hi" return $page; } // call staticaly by class name public static function TestFunctionStatic() { $page = "hi" return $page; } } this example help you to understand // create object instance $testObj = new ClassName(); // call public method $testObj->TestFunction(); // will return "hi" // call static method $testObj = ClassName::TestFunctionStatic(); // $testObj now contains "hi"
  3. Я имею в виду изменения через SQL запросы. Но для этого, конечно же, нужны базовые знания SQL и понимание как в Престе хранятся данные о товарах в базе данных. Иногда нужно с большим кол-вом товара выполнить какие-то массовые действия, разово... и модуль для этого покупать или писать как-то нецелесообразно. Для изменения категории товара нужно в двух таблицах изменить id категории товара и все. Но опять-же, это MySQL и написание простейшего запроса.
  4. Не готов сходу код написать, это смотреть надо. Но принцип тот же... все по аналогии.
  5. A SQL запрос не подходит? Можно сколько угодно товаров перенести в любые категории....
  6. Смотреть этот блок и по аналогии сделать. Можно все это дело вынести в отдельный темплейт и использовать его как плагин в нужных местах хоть по всему сайту.
  7. debug show you variable and it`s values. Of course variable has named as $products. But... to access the value, you need write like this - $products[0]['product_id'] or use cycle (iteration). In this case we use $products for ($i = 0; $ < $endOfProducts; $i++) { echo $products[$i]['name']; } In templates use other constructions: foreach ($names as $name) foreach ($products as $product) { echo $product['name']; } see more info about this construction in php.net
  8. С таким кол-вом товаров на Престе тяжеловато... Думаю, если включить профайлер и посмотреть на кол-во запросов, инстансов и потребление памяти, то очевидно должно стать то, что над некоторыми алгоритмами нужно поработать. А там есть над чем работать....
  9. $products - it`s multidimensional array(), it contains many arrays in single array. $products = array( 0 => array ( 'id_product' => 1, 'name' => 'name1', ....), 1 => array ( 'id_product' => 2, 'name' => 'name2', ....), .... ); So, you can access to item 'name' by array index: $products[1]['name'] –> display 'name2' Or: foreach($products as $product) { $product_name = $product['name]; } Variable $product_name will contains values 'name' –> name1, name2... ect... Presta use second way but in this case PHP create the copy of array... sometimes Your second questions about Object Oriented Programming. "–>" - It`s like a special variable and it refers to the member variable inside object. The official PHP name is "object operator". It`s came from C++ and how works with memory in direct. "." - it`s almost same, but in JAVA style In C++ you can create object in stack or heap. And you can work with memory directly. PHP can`t work with memory directly. For example: // C++ #include <iostream> class Point { private: double x; double y; public: Point(double x=0, double y=0) { this->x = x; this->y = y; } ~Point(); double getX() const { return this->x; } double getY() const { return this->x; } }; int main() { Point* pointA = new Point(3.00, 5.89); std::cout << "Point A: x = " << (*pointA).getX() << std::cout << std::endl; delete pointA; return 0; } same in PHP: <?php class Point { private $x; private $y; public function __construct ($x = 0, $y = 0) { $this->x = $this->validate($x); $this->y = $this->validate($y); } public function __destruct() {} private function validate($num) { if(is_numeric($num)) { return $num; } throw new Exception('Invalid param'); } public function __get($name) { if ( property_exists($this, $name) ) { return $this->$name; } throw new Exception("Attribute error: attribute $name not found"); } public function __set($name, $value) { if ( property_exists($this, $name) ) { $this->$name = $this->validate($value); } throw new Exception("Attribute error: attribute $name not found"); } public function __toString() { return sprintf("(%g, %g)", $this->x, $this->y); } public function doSomething() { echo 'Something strange....'; } } $pointA = new Point(3.0, 5.89); echo 'Point A:' . $pointA . PHP_EOL; $pointA->doSomething(); unset($pointA); ?> Right documentation: php.net
  10. In the product_list.tpl var $products contains product array. Structure of the array is next: array (size=7) 0 => array (size=83) 'id_product' => string '1' (length=1) 'id_supplier' => string '1' (length=1) 'id_manufacturer' => string '1' (length=1) 'id_category_default' => string '5' (length=1) 'id_shop_default' => string '1' (length=1) 'id_tax_rules_group' => string '1' (length=1) 'on_sale' => string '0' (length=1) 'online_only' => string '0' (length=1) 'ean13' => string '0' (length=1) 'upc' => string '' (length=0) 'ecotax' => string '0.000000' (length=8) 'quantity' => int 299 'minimal_quantity' => string '1' (length=1) 'price' => float 19.2 'wholesale_price' => string '5.000000' (length=8) 'unity' => string '' (length=0) 'unit_price_ratio' => string '0.000000' (length=8) 'additional_shipping_cost' => string '0.00' (length=4) 'reference' => string 'demo_1' (length=6) 'supplier_reference' => string '' (length=0) 'location' => string '' (length=0) 'width' => string '0.000000' (length=8) 'height' => string '0.000000' (length=8) 'depth' => string '0.000000' (length=8) 'weight' => string '0.000000' (length=8) 'out_of_stock' => string '2' (length=1) 'quantity_discount' => string '0' (length=1) 'customizable' => string '0' (length=1) 'uploadable_files' => string '0' (length=1) 'text_fields' => string '0' (length=1) 'active' => string '1' (length=1) 'redirect_type' => string '404' (length=3) 'id_product_redirected' => string '0' (length=1) 'available_for_order' => string '1' (length=1) 'available_date' => string '0000-00-00' (length=10) 'condition' => string 'new' (length=3) 'show_price' => string '1' (length=1) 'indexed' => string '1' (length=1) 'visibility' => string 'both' (length=4) 'cache_is_pack' => string '0' (length=1) 'cache_has_attachments' => string '0' (length=1) 'is_virtual' => string '0' (length=1) 'cache_default_attribute' => string '1' (length=1) 'date_add' => string '2015-11-16 14:34:38' (length=19) 'date_upd' => string '2016-09-09 11:16:11' (length=19) 'advanced_stock_management' => string '0' (length=1) 'pack_stock_type' => string '3' (length=1) 'id_shop' => string '1' (length=1) 'id_lang' => string '1' (length=1) 'description' => string '<p>Fashion has been creating well-designed collections since 2010. The brand offers feminine designs delivering stylish separates and statement dresses which has since evolved into a full ready-to-wear collection in which every item is a vital part of a woman's wardrobe. The result? Cool, easy, chic looks with youthful elegance and unmistakable signature style. All the beautiful pieces are made in Italy and manufactured with the greatest attention. Now Fashion extends to a range of accessories including sho'... (length=541) 'description_short' => string '<p>Faded short sleeve t-shirt with high neckline. Soft and stretchy material for a comfortable fit. Accessorize with a straw hat and you're ready for summer!</p>' (length=161) 'link_rewrite' => string 'faded-short-sleeve-tshirts' (length=26) 'meta_description' => string '' (length=0) 'meta_keywords' => string '' (length=0) 'meta_title' => string '' (length=0) 'name' => string 'Faded Short Sleeve T-shirts' (length=27) 'available_now' => string 'In stock' (length=8) 'available_later' => string '' (length=0) 'id_image' => string '1-1' (length=3) 'legend' => string '' (length=0) 'manufacturer_name' => string 'Fashion Manufacturer' (length=20) 'id_product_attribute' => int 1 'new' => string '0' (length=1) 'product_attribute_minimal_quantity' => string '1' (length=1) 'allow_oosp' => int 0 'category' => string 'tshirts' (length=7) 'link' => string 'http://someURL/1-faded-short-sleeve-tshirts.html' (length=73) 'attribute_price' => float 0 'price_tax_exc' => float 16 'price_without_reduction' => float 19.2 'reduction' => float 0 'specific_prices' => boolean false 'quantity_all_versions' => int 1799 'features' => array (size=3) 0 => array (size=3) ... 1 => array (size=3) ... 2 => array (size=3) ... 'attachments' => array (size=0) empty 'virtual' => int 0 'pack' => int 0 'packItems' => array (size=0) empty 'nopackprice' => int 0 'customization_required' => boolean false 'rate' => float 20 'tax_name' => string '20%' (length=10) 'color_list' => string Features are also ARRAY! So, you need write like this: {$product.features[0].name} {$product.features[0].value} for example. See in my picture bellow - Product Name (Feature Name: Feature Value)
  11. Task for example: I`ll print feature name and value after product name on the product page. Let`s go - open file product.tpl and find var {$product.name ....} Next - i`ll try to print features array for understanding how it looks. After <h1> i print features var... <h1 itemprop="name">{$product->name|escape:'html':'UTF-8'}</h1> {$features|@var_dump} and we see this result: Next, i print one feature name and value after product name. <h1 itemprop="name">{$product->name|escape:'html':'UTF-8'} | {$features[0].name} - {$features[0].value} </h1> $features - it`s simple array(), use Smarty documentation for understanding how work with arrays.
  12. 1. Проверяем, чтоб в Престе были установлены и настроены: Google Analytics API / Аналитика Google 2. В аккаунте Аналитики в настройках электронной торговли включаем электронную торговлю и расширенную электронную торговлю. 3. Через Google Chrome проверяем отдает ли сайт данные об электронной торговле в аналитику (расширение Google Analytics Debugger / Tag Assistant) 4. Настраиваем цели и события в самой аналитике.
  13. You need to override function generateReference() in classes/order/Order.php this function return reference generated by Tools class. For example: select from DB last order_id, then increment by 1 and return this as function result. WEB - prefix, which gets from presences; 2016 - year generated with data('Y'); 00001 - reference, generated by func genereteReference(); "-" - separator; it`s simply...
  14. Тогда я могу только представить масштабы по оптимизации.... У меня были несколько шаблонов, которые явно были созданы при помощи какого-то "конструктора". О скорости там не приходилось говорить в принципе. Все что можно было сделать при помощи массивов - все было сделано именно так, CSS стили модулей часто дублировали друг друга или переопределяли уже существующие стили.... и главная страница загружалась так медленно, что помогало только полное отключение всех сторонних модулей. К сожалению, готовых решений для такого рода задач - нету. И часто бывает даже так, что проект приходится переделывать, потому, что разбираться в тоннах кода, решающего минималистистические задачи, совсем нет ни времени, ни желания.
  15. Тут нужно понять, что именно при первом обращении создает такую задержку. Это могут быть скрипты, которые выполняют кучу второстепенных действий в то время, когда должна грузиться страница, это может быть и рендер с многократными пересчетами CSS и даже модуль "какие-то там очень популярные товары..." который дергает при обращении кучу компонентов и лезет каждый раз в базу данных... Дайте ссылку на сайт, попробую посмотреть. Чтобы уменьшить время загрузки нужно минимизировать (кешировать) сторонние скрипты, разделить CSS и даже частично что-то из правил поместить в начало страницы (посмотрите рекомендации гугла по АМР) и внимательно, крайне внимательно посмотреть на реализацию любых модулей "не из коробки". Еще неплохо бы посмотреть настройки серверной части, может оказаться, что не все работает так как это предполагается...
×
×
  • Create New...