Code Duplication    Length = 14-16 lines in 2 locations

class/oledrion_products.php 2 locations

@@ 672-685 (lines=14) @@
669
     *
670
     * @return integer Le nombre total de produits recommandés
671
     */
672
    public function getRecommendedCount()
673
    {
674
        $criteria = new CriteriaCompo();
675
        $criteria->add(new Criteria('product_online', 1, '='));
676
        $criteria->add(new Criteria('product_recommended', '0000-00-00', '<>'));
677
        if (Oledrion_utils::getModuleOption('show_unpublished') == 0) { // Ne pas afficher les produits qui ne sont pas publiés
678
            $criteria->add(new Criteria('product_submitted', time(), '<='));
679
        }
680
        if (Oledrion_utils::getModuleOption('nostock_display') == 0) { // Se limiter aux seuls produits encore en stock
681
            $criteria->add(new Criteria('product_stock', 0, '>'));
682
        }
683
684
        return $this->getCount($criteria);
685
    }
686
687
    /**
688
     * Retourne la liste des x derniers produits parus toutes catégories confondues ou dans une catégorie spécifique
@@ 823-838 (lines=16) @@
820
     * @param  int|intefer $product_cid Catégorie du produit
821
     * @return int         Le nombre de produits publiés
822
     */
823
    public function getTotalPublishedProductsCount($product_cid = 0)
824
    {
825
        $criteria = new CriteriaCompo();
826
        $criteria->add(new Criteria('product_online', 1, '='));
827
        if (Oledrion_utils::getModuleOption('show_unpublished') == 0) { // Ne pas afficher les produits qui ne sont pas publiés
828
            $criteria->add(new Criteria('product_submitted', time(), '<='));
829
        }
830
        if (Oledrion_utils::getModuleOption('nostock_display') == 0) { // Se limiter aux seuls produits encore en stock
831
            $criteria->add(new Criteria('product_stock', 0, '>'));
832
        }
833
        if ($product_cid > 0) {
834
            $criteria->add(new Criteria('product_cid', (int)$product_cid, '='));
835
        }
836
837
        return $this->getCount($criteria);
838
    }
839
840
    /**
841
     * Récupération de l'ID et du titre d'une série de produits répondants à un critère