Updated: Changes for PHP 8.x compatibility
This commit is contained in:
@@ -259,6 +259,13 @@ class ProductCore extends ObjectModel
|
||||
*/
|
||||
public $pack_stock_type = 3;
|
||||
|
||||
public $productDownload;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
public $customization_required;
|
||||
|
||||
public static $_taxCalculationMethod = null;
|
||||
protected static $_prices = array();
|
||||
protected static $_pricesLevel2 = array();
|
||||
@@ -566,7 +573,7 @@ class ProductCore extends ObjectModel
|
||||
const STANDARD_PRODUCT_ADDRESS_PREFERENCE_HOTEL = 2;
|
||||
const STANDARD_PRODUCT_ADDRESS_PREFERENCE_CUSTOM = 3;
|
||||
|
||||
public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
|
||||
public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, ?Context $context = null)
|
||||
{
|
||||
parent::__construct($id_product, $id_lang, $id_shop);
|
||||
if ($full && $this->id) {
|
||||
@@ -1247,7 +1254,7 @@ class ProductCore extends ObjectModel
|
||||
$return = Db::getInstance()->delete('category_product', 'id_product = '.(int)$this->id.' AND id_category = '.(int)$id_category);
|
||||
if ($clean_positions === true) {
|
||||
foreach ($result as $row) {
|
||||
$this->cleanPositions((int)$row['id_category'], (int)$row['position']);
|
||||
Product::cleanPositions((int)$row['id_category'], (int)$row['position']);
|
||||
}
|
||||
}
|
||||
SpecificPriceRule::applyAllRules(array((int)$this->id));
|
||||
@@ -1273,7 +1280,7 @@ class ProductCore extends ObjectModel
|
||||
$return = Db::getInstance()->delete('category_product', 'id_product = '.(int)$this->id);
|
||||
if ($clean_positions === true && is_array($result)) {
|
||||
foreach ($result as $row) {
|
||||
$return &= $this->cleanPositions((int)$row['id_category'], (int)$row['position']);
|
||||
$return &= Product::cleanPositions((int)$row['id_category'], (int)$row['position']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1342,7 +1349,7 @@ class ProductCore extends ObjectModel
|
||||
* @return array Products details
|
||||
*/
|
||||
public static function getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category = false,
|
||||
$only_active = false, Context $context = null)
|
||||
$only_active = false, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -1394,7 +1401,7 @@ class ProductCore extends ObjectModel
|
||||
return ($rq);
|
||||
}
|
||||
|
||||
public static function getSimpleProducts($id_lang, Context $context = null)
|
||||
public static function getSimpleProducts($id_lang, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -1416,7 +1423,7 @@ class ProductCore extends ObjectModel
|
||||
}
|
||||
|
||||
|
||||
public function getProductServiceProducts($id_lang, $p, $n, $front = false, $available_for_order = 2, $auto_add_to_cart = 0, $get_total = false, $active = true, $sub_category = false, Context $context = null)
|
||||
public function getProductServiceProducts($id_lang, $p, $n, $front = false, $available_for_order = 2, $auto_add_to_cart = 0, $get_total = false, $active = true, $sub_category = false, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -1503,7 +1510,7 @@ class ProductCore extends ObjectModel
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getAvailableServiceProductsCategories($id_lang, $front = false, $active = true, Context $context = null)
|
||||
public function getAvailableServiceProductsCategories($id_lang, $front = false, $active = true, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -1584,7 +1591,7 @@ class ProductCore extends ObjectModel
|
||||
return count($result) > 0;
|
||||
}
|
||||
|
||||
public function productAttributeExists($attributes_list, $current_product_attribute = false, Context $context = null, $all_shops = false, $return_id = false)
|
||||
public function productAttributeExists($attributes_list, $current_product_attribute = false, ?Context $context = null, $all_shops = false, $return_id = false)
|
||||
{
|
||||
if (!Combination::isFeatureActive()) {
|
||||
return false;
|
||||
@@ -1631,38 +1638,6 @@ class ProductCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* addProductAttribute is deprecated
|
||||
*
|
||||
* The quantity params now set StockAvailable for the current shop with the specified quantity
|
||||
* The supplier_reference params now set the supplier reference of the default supplier of the product if possible
|
||||
*
|
||||
* @see StockManager if you want to manage real stock
|
||||
* @see StockAvailable if you want to manage available quantities for sale on your shop(s)
|
||||
* @see ProductSupplier for manage supplier reference(s)
|
||||
*
|
||||
* @deprecated since 1.5.0
|
||||
*/
|
||||
public function addProductAttribute($price, $weight, $unit_impact, $ecotax, $quantity, $id_images, $reference,
|
||||
$id_supplier = null, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
|
||||
$id_product_attribute = $this->addAttribute(
|
||||
$price, $weight, $unit_impact, $ecotax, $id_images,
|
||||
$reference, $ean13, $default, $location, $upc, $minimal_quantity
|
||||
);
|
||||
|
||||
if (!$id_product_attribute) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StockAvailable::setQuantity($this->id, $id_product_attribute, $quantity);
|
||||
//Try to set the default supplier reference
|
||||
$this->addSupplierReference($id_supplier, $id_product_attribute);
|
||||
return $id_product_attribute;
|
||||
}
|
||||
|
||||
public function generateMultipleCombinations($combinations, $attributes)
|
||||
{
|
||||
$res = true;
|
||||
@@ -1803,28 +1778,6 @@ class ProductCore extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a product attribute
|
||||
*
|
||||
* @deprecated since 1.5
|
||||
* @see updateAttribute() to use instead
|
||||
* @see ProductSupplier for manage supplier reference(s)
|
||||
*
|
||||
*/
|
||||
public function updateProductAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax,
|
||||
$id_images, $reference, $id_supplier = null, $ean13, $default, $location = null, $upc = null, $minimal_quantity, $available_date)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
|
||||
$return = $this->updateAttribute(
|
||||
$id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax,
|
||||
$id_images, $reference, $ean13, $default, $location = null, $upc = null, $minimal_quantity, $available_date
|
||||
);
|
||||
$this->addSupplierReference($id_supplier, $id_product_attribute);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or updates Supplier Reference
|
||||
*
|
||||
@@ -2550,7 +2503,7 @@ class ProductCore extends ObjectModel
|
||||
* @param int $nbProducts Number of products to return (optional)
|
||||
* @return array New products
|
||||
*/
|
||||
public static function getNewProducts($id_lang, $page_number = 0, $nb_products = 10, $count = false, $order_by = null, $order_way = null, Context $context = null)
|
||||
public static function getNewProducts($id_lang, $page_number = 0, $nb_products = 10, $count = false, $order_by = null, $order_way = null, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -2664,7 +2617,7 @@ class ProductCore extends ObjectModel
|
||||
return Product::getProductsProperties((int)$id_lang, $result);
|
||||
}
|
||||
|
||||
protected static function _getProductIdByDate($beginning, $ending, Context $context = null, $with_combination = false)
|
||||
protected static function _getProductIdByDate($beginning, $ending, ?Context $context = null, $with_combination = false)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -2698,7 +2651,7 @@ class ProductCore extends ObjectModel
|
||||
* @param int $id_lang Language id
|
||||
* @return array Special
|
||||
*/
|
||||
public static function getRandomSpecial($id_lang, $beginning = false, $ending = false, Context $context = null)
|
||||
public static function getRandomSpecial($id_lang, $beginning = false, $ending = false, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -2791,7 +2744,7 @@ class ProductCore extends ObjectModel
|
||||
* @return array Prices drop
|
||||
*/
|
||||
public static function getPricesDrop($id_lang, $page_number = 0, $nb_products = 10, $count = false,
|
||||
$order_by = null, $order_way = null, $beginning = false, $ending = false, Context $context = null)
|
||||
$order_by = null, $order_way = null, $beginning = false, $ending = false, ?Context $context = null)
|
||||
{
|
||||
if (!Validate::isBool($count)) {
|
||||
die(Tools::displayError());
|
||||
@@ -3022,7 +2975,7 @@ class ProductCore extends ObjectModel
|
||||
* @param int $id_lang Language id for multilingual legends
|
||||
* @return array Product images and legends
|
||||
*/
|
||||
public function getImages($id_lang, Context $context = null)
|
||||
public function getImages($id_lang, ?Context $context = null)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT image_shop.`cover`, i.`id_image`, il.`legend`, i.`position`
|
||||
@@ -3039,7 +2992,7 @@ class ProductCore extends ObjectModel
|
||||
*
|
||||
* @return array Product cover image
|
||||
*/
|
||||
public static function getCover($id_product, Context $context = null)
|
||||
public static function getCover($id_product, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -3088,7 +3041,7 @@ class ProductCore extends ObjectModel
|
||||
*/
|
||||
public static function getPriceStatic($id_product, $usetax = true, $id_product_attribute = null, $decimals = 6, $divisor = null,
|
||||
$only_reduc = false, $usereduc = true, $quantity = 1, $force_associated_tax = false, $id_customer = null, $id_cart = null,
|
||||
$id_address = null, &$specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, Context $context = null,
|
||||
$id_address = null, &$specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, ?Context $context = null,
|
||||
$use_customer_price = true, $id_hotel = false, $id_product_room_type = false, $id_group = null)
|
||||
{
|
||||
if (!$context) {
|
||||
@@ -3527,7 +3480,7 @@ class ProductCore extends ObjectModel
|
||||
return self::$_prices[$cache_id];
|
||||
}
|
||||
|
||||
public static function convertAndFormatPrice($price, $currency = false, Context $context = null)
|
||||
public static function convertAndFormatPrice($price, $currency = false, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -3538,7 +3491,7 @@ class ProductCore extends ObjectModel
|
||||
return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency);
|
||||
}
|
||||
|
||||
public static function isDiscounted($id_product, $quantity = 1, Context $context = null)
|
||||
public static function isDiscounted($id_product, $quantity = 1, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -3694,7 +3647,7 @@ class ProductCore extends ObjectModel
|
||||
* @param Shop $shop
|
||||
* @return string
|
||||
*/
|
||||
public static function sqlStock($product_alias, $product_attribute = null, $inner_join = false, Shop $shop = null)
|
||||
public static function sqlStock($product_alias, $product_attribute = null, $inner_join = false, ?Shop $shop = null)
|
||||
{
|
||||
$id_shop = ($shop !== null ? (int)$shop->id : null);
|
||||
$sql = (($inner_join) ? ' INNER ' : ' LEFT ')
|
||||
@@ -3785,7 +3738,7 @@ class ProductCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isAvailableWhenOutOfStock(StockAvailable::outOfStock($this->id))) {
|
||||
if (Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($this->id))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4007,7 +3960,7 @@ class ProductCore extends ObjectModel
|
||||
$row['id_product_attribute'] = Product::getDefaultAttribute((int)$row['id_product']);
|
||||
}
|
||||
|
||||
return $this->getProductsProperties($id_lang, $result);
|
||||
return Product::getProductsProperties($id_lang, $result);
|
||||
}
|
||||
|
||||
public static function getAccessoryById($accessory_id)
|
||||
@@ -4160,7 +4113,7 @@ class ProductCore extends ObjectModel
|
||||
* @param string $query Search query
|
||||
* @return array Matching products
|
||||
*/
|
||||
public static function searchByName($id_lang, $query, $booking_product = null, $selling_preference_type = null, $id_hotel = false, Context $context = null)
|
||||
public static function searchByName($id_lang, $query, $booking_product = null, $selling_preference_type = null, $id_hotel = false, ?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -4624,7 +4577,7 @@ class ProductCore extends ObjectModel
|
||||
/**
|
||||
* Get the link of the product page of this product
|
||||
*/
|
||||
public function getLink(Context $context = null)
|
||||
public function getLink(?Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -4659,7 +4612,7 @@ class ProductCore extends ObjectModel
|
||||
return Language::getIsoById((int)$id_lang).'-default';
|
||||
}
|
||||
|
||||
public static function getProductProperties($id_lang, $row, Context $context = null)
|
||||
public static function getProductProperties($id_lang, $row, ?Context $context = null)
|
||||
{
|
||||
if (!$row['id_product']) {
|
||||
return false;
|
||||
@@ -4813,7 +4766,7 @@ class ProductCore extends ObjectModel
|
||||
return self::$producPropertiesCache[$cache_key];
|
||||
}
|
||||
|
||||
public static function getTaxesInformations($row, Context $context = null)
|
||||
public static function getTaxesInformations($row, ?Context $context = null)
|
||||
{
|
||||
static $address = null;
|
||||
|
||||
@@ -5253,7 +5206,7 @@ class ProductCore extends ObjectModel
|
||||
);
|
||||
}
|
||||
|
||||
public function hasAllRequiredCustomizableFields(Context $context = null)
|
||||
public function hasAllRequiredCustomizableFields(?Context $context = null)
|
||||
{
|
||||
if (!Customization::isFeatureActive()) {
|
||||
return true;
|
||||
@@ -5463,7 +5416,7 @@ class ProductCore extends ObjectModel
|
||||
* @param Address|null $address
|
||||
* @return float The total taxes rate applied to the product
|
||||
*/
|
||||
public function getTaxesRate(Address $address = null)
|
||||
public function getTaxesRate(?Address $address = null)
|
||||
{
|
||||
if (!$address || !$address->id_country) {
|
||||
$address = Address::initialize(Cart::getIdAddressForTaxCalculation($this->id));
|
||||
@@ -5834,7 +5787,7 @@ class ProductCore extends ObjectModel
|
||||
*/
|
||||
public function getCoverWs()
|
||||
{
|
||||
if ($result = $this->getCover($this->id)) {
|
||||
if ($result = Product::getCover($this->id)) {
|
||||
return $result['id_image'];
|
||||
}
|
||||
|
||||
@@ -6116,7 +6069,7 @@ class ProductCore extends ObjectModel
|
||||
// save room type info adults, child, hotel info
|
||||
$postData = trim(file_get_contents('php://input'));
|
||||
libxml_use_internal_errors(true);
|
||||
$xml = simplexml_load_string(utf8_decode($postData));
|
||||
$xml = simplexml_load_string(mb_convert_encoding($postData, 'ISO-8859-1'));
|
||||
|
||||
$roomtypeData = json_decode(json_encode($xml), true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user