Пример #1
0
 public function clearCache($all = false)
 {
     if ($all) {
         JeproshopCache::clean('jeproshop_image_model_*');
     } elseif ($this->image_id) {
         JeproshopCache::clean('jeproshop_image_model_' . (int) $this->image_id . '_*');
     }
 }
Пример #2
0
 /**
  * Removes a given product from the stock available
  *
  * @param int $product_id
  * @param int $product_attribute_id Optional
  * @param mixed $shop shop id or shop object Optional
  */
 public static function removeProductFromStockAvailable($product_id, $product_attribute_id = null, $shop = null)
 {
     if (!JeproshopTools::isUnsignedInt($product_id)) {
         return false;
     }
     $db = JFactory::getDBO();
     if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
         if (JeproshopShopModelShop::getContextShopGroup()->share_stock == 1) {
             $product_attribute_sql = '';
             if ($product_attribute_id !== null) {
                 $product_attribute_sql = '_attribute';
                 $product_attribute_id_sql = $product_attribute_id;
             } else {
                 $product_attribute_id_sql = $product_id;
             }
             $query = "SELECT COUNT(*) FROM " . $db->quoteName('#__jeproshop_product' . $product_attribute_sql . '_shop') . " WHERE " . $db->quoteName('product' . $product_attribute_sql . '_id') . " = ";
             $query .= (int) $product_attribute_id_sql . " AND " . $db->quoteName('shop_id') . " IN (" . implode(',', array_map('intval', JeproshopShopModelShop::getContextListShopIds(JeproshopShopModelShop::SHARE_STOCK))) . ")";
             $db->setQuery($query);
             $result = (int) $db->loadResult();
             if ($result) {
                 return true;
             }
         }
     }
     $query = "DELETE FROM " . $db->quoteName('#__jeproshop_stock_available') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product_id;
     $query .= ($product_attribute_id ? " AND " . $db->quoteName('product_attribute_id') . " = " . (int) $product_attribute_id : "") . JeproshopStockAvailableModelStockAvailable::addShopRestriction(null, $shop);
     $db->setQuery($query);
     $res = $db->query();
     if ($product_attribute_id) {
         if ($shop === null || !JeproshopTools::isLoadedObject($shop, 'shop_id')) {
             $shop_datas = new Object();
             JeproshopStockAvailableModelStockAvailable::addSqlShopParams($shop_datas);
             $shop_id = (int) $shop_datas->shop_id;
         } else {
             $shop_id = (int) $shop->shop_id;
         }
         $stock_available = new JeproshopStockAvailableModelStockAvailable();
         $stock_available->product_id = (int) $product_id;
         $stock_available->product_attribute_id = (int) $product_id;
         $stock_available->shop_id = (int) $shop_id;
         $stock_available->postSave();
     }
     JeproshopCache::clean('jeproshop_stock_available_get-quantity_Available_by_product_' . (int) $product_id . '_*');
     return $res;
 }
Пример #3
0
 /**
  * Set the delivery option and carrier_id, if there is only one carrier
  */
 public function setDeliveryOption($delivery_option = null)
 {
     if (empty($delivery_option) || count($delivery_option) == 0) {
         $this->delivery_option = '';
         $this->carrier_id = 0;
         return;
     }
     JeproshopCache::clean('getContextualValue_*');
     $delivery_option_list = $this->getDeliveryOptionList(null, true);
     foreach ($delivery_option_list as $address_id => $options) {
         if (!isset($delivery_option[$address_id])) {
             foreach ($options as $key => $option) {
                 if ($option['is_best_price']) {
                     $delivery_option[$address_id] = $key;
                     break;
                 }
             }
         }
     }
     if (count($delivery_option) == 1) {
         $this->carrier_id = $this->getIdCarrierFromDeliveryOption($delivery_option);
     }
     $this->delivery_option = serialize($delivery_option);
 }
Пример #4
0
 public function clearCache($all = false)
 {
     if ($all) {
         JeproshopCache::clean('jeproshop_model_category_*');
     } elseif ($this->category_id) {
         JeproshopCache::clean('jeproshop_model_category_' . (int) $this->category_id . '_*');
     }
 }
Пример #5
0
 private function clearCache($all = FALSE)
 {
     if ($all) {
         JeproshopCache::clean('jeproshop_product_model_*');
     } elseif ($this->product_id) {
         JeproshopCache::clean('jeproshop_product_model_' . $this->product_id . '_*');
     }
 }