XoopsModules25x /
oledrion
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace XoopsModules\Oledrion; |
||||||
| 4 | |||||||
| 5 | /* |
||||||
| 6 | You may not change or alter any portion of this comment or credits |
||||||
| 7 | of supporting developers from this source code or any supporting source code |
||||||
| 8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 9 | |||||||
| 10 | This program is distributed in the hope that it will be useful, |
||||||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 13 | */ |
||||||
| 14 | |||||||
| 15 | /** |
||||||
| 16 | * oledrion |
||||||
| 17 | * |
||||||
| 18 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||||
| 19 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||||||
| 20 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||||||
| 21 | */ |
||||||
| 22 | |||||||
| 23 | /** |
||||||
| 24 | * Gestion des produits relatifs |
||||||
| 25 | */ |
||||||
| 26 | |||||||
| 27 | use XoopsModules\Oledrion; |
||||||
| 28 | |||||||
| 29 | /** |
||||||
| 30 | * Class RelatedHandler |
||||||
| 31 | */ |
||||||
| 32 | class RelatedHandler extends OledrionPersistableObjectHandler |
||||||
| 33 | { |
||||||
| 34 | /** |
||||||
| 35 | * RelatedHandler constructor. |
||||||
| 36 | * @param \XoopsDatabase|null $db |
||||||
| 37 | */ |
||||||
| 38 | public function __construct(\XoopsDatabase $db = null) |
||||||
| 39 | { |
||||||
| 40 | // Table Classe Id |
||||||
| 41 | parent::__construct($db, 'oledrion_related', Related::class, 'related_id'); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 42 | } |
||||||
| 43 | |||||||
| 44 | /** |
||||||
| 45 | * Supprime les produits relatifs rattachés à un produit |
||||||
| 46 | * |
||||||
| 47 | * @param int $related_product_id L'identifiant du produit pour lequel il faut faire la suppression |
||||||
| 48 | */ |
||||||
| 49 | public function deleteProductRelatedProducts($related_product_id) |
||||||
| 50 | { |
||||||
| 51 | $criteria = new \Criteria('related_product_id', $related_product_id, '='); |
||||||
| 52 | $this->deleteAll($criteria); |
||||||
| 53 | } |
||||||
| 54 | |||||||
| 55 | /** |
||||||
| 56 | * Retourne la liste des produits relatifs d'une liste de produits |
||||||
| 57 | * |
||||||
| 58 | * @param array $ids Les ID des produits dont on recherche les produits relatifs |
||||||
| 59 | * @return array Objets de type Related |
||||||
| 60 | */ |
||||||
| 61 | public function getRelatedProductsFromProductsIds($ids) |
||||||
| 62 | { |
||||||
| 63 | $ret = []; |
||||||
| 64 | if (is_array($ids)) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 65 | $criteria = new \Criteria('related_product_id', '(' . implode(',', $ids) . ')', 'IN'); |
||||||
| 66 | $ret = $this->getObjects($criteria, true, true, '*', false); |
||||||
|
0 ignored issues
–
show
The call to
XoopsPersistableObjectHandler::getObjects() has too many arguments starting with '*'.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||||
| 67 | } |
||||||
| 68 | |||||||
| 69 | return $ret; |
||||||
| 70 | } |
||||||
| 71 | |||||||
| 72 | /** |
||||||
| 73 | * Update product percent |
||||||
| 74 | * |
||||||
| 75 | * @param $id |
||||||
| 76 | * @param $related |
||||||
| 77 | * @param $percent |
||||||
| 78 | * @return bool |
||||||
| 79 | * @internal param $ |
||||||
| 80 | */ |
||||||
| 81 | public function updatePercent($id, $related, $percent) |
||||||
| 82 | { |
||||||
| 83 | if ($percent > 100) { |
||||||
| 84 | return false; |
||||||
| 85 | } |
||||||
| 86 | |||||||
| 87 | $sql = 'UPDATE ' . $this->table . ' SET `related_product_percent` = ' . (int)$percent . ' WHERE (related_product_id = ' . (int)$id . ') AND (related_product_related = ' . (int)$related . ')'; |
||||||
| 88 | |||||||
| 89 | return $this->db->queryF($sql); |
||||||
| 90 | } |
||||||
| 91 | } |
||||||
| 92 |