diff --git a/README.md b/README.md index ecb5119..9101bc6 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Enrich your stats, display a table of your latest orders and a ranking of your products. +## Compatibility + +PrestaShop: `1.7.6.0` or later + ## Reporting issues You can report issues with this module in the main PrestaShop repository. [Click here to report an issue][report-issue]. @@ -19,6 +23,6 @@ Just make sure to follow our [contribution guidelines][contribution-guidelines]. This module is released under the [Academic Free License 3.0][AFL-3.0] [report-issue]: https://github.com/PrestaShop/PrestaShop/issues/new/choose -[prestashop]: https://www.prestashop.com/ +[prestashop]: https://www.prestashop-project.org/ [contribution-guidelines]: https://devdocs.prestashop.com/1.7/contribute/contribution-guidelines/project-modules/ [AFL-3.0]: https://opensource.org/licenses/AFL-3.0 diff --git a/config.xml b/config.xml index c03cd01..1b73f53 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ dashproducts - + diff --git a/dashproducts.php b/dashproducts.php index 8b4be2c..34f7b22 100755 --- a/dashproducts.php +++ b/dashproducts.php @@ -33,7 +33,7 @@ public function __construct() { $this->name = 'dashproducts'; $this->tab = 'administration'; - $this->version = '2.1.3'; + $this->version = '2.1.4'; $this->author = 'PrestaShop'; parent::__construct(); @@ -148,7 +148,7 @@ public function getTableRecentOrders() 'id' => 'details', 'value' => '', 'class' => 'text-right', - 'wrapper_start' => '', + 'wrapper_start' => '', 'wrapper_end' => '', ]; @@ -221,12 +221,17 @@ public function getTableBestSellers($date_from, $date_to) if (!Validate::isLoadedObject($product_obj)) { continue; } - $category = new Category($product_obj->getDefaultCategory()['id_category_default'], $this->context->language->id); + + $productCategoryId = $product_obj->getDefaultCategory(); + if (is_array($productCategoryId) && isset($productCategoryId['id_category_default'])) { + $productCategoryId = $productCategoryId['id_category_default']; + } + $category = new Category($productCategoryId, $this->context->language->id); $img = ''; if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) { $image = new Image((int) $row_image['id_image']); - $path_to_image = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; + $path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; $img = ImageManager::thumbnail($path_to_image, 'product_mini_' . $row_image['id_image'] . '.' . $this->context->controller->imageType, 45, $this->context->controller->imageType); } @@ -321,7 +326,7 @@ public function getTableMostViewed($date_from, $date_to) $img = ''; if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) { $image = new Image((int) $row_image['id_image']); - $path_to_image = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; + $path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; $img = ImageManager::thumbnail( $path_to_image, 'product_mini_' . $product_obj->id . '.' . $this->context->controller->imageType,