protected static function getDbConnection() { if (self::$_connection === null) { self::$_connection = self::getDbResource()->getConnection('core_read'); } return self::$_connection; }
public function clearCacheAction() { $tableName = Vikont_Fitment_Helper_Db::getDbResource()->getTableName('core/config_data'); $sql = 'DELETE FROM ' . $tableName . ' WHERE path LIKE "fitment/cache/%"'; Vikont_Fitment_Helper_Db::executeQuery($sql); die; }
public function detectSimpleProduct($ariProductId, $ariActivityId, $fitmentId = null) { /* $skuInfo = Mage::helper('fitment/api') ->preventErrorReporting() ->request('fitmentnotes', array( 'productID' => $ariProductId, 'fitmentID' => $fitmentId, ) );/**/ $skuInfo = Mage::helper('fitment/api')->request('skuinfo', array('activityId' => $ariActivityId, 'productId' => $ariProductId), array('fitmentId' => $fitmentId)); Mage::register('skuInfo', $skuInfo); if (!count($skuInfo)) { Mage::log(sprintf('ERROR: Unable to find product: SKU info is empty: ARI activity=%d, ARI product=%d, fitment=%d', $ariActivityId, $ariProductId, $fitmentId)); // Mage::log(sprintf('ERROR: Unable to find product: SKU info is empty: ARI product=%d, fitment=%d', // $ariProductId, $fitmentId)); return null; } $skus = array(); foreach ($skuInfo as $skuInfoItem) { $skus[] = $skuInfoItem['Id']; // $skus[] = $skuInfoItem['SkuId']; } $productId = Vikont_Fitment_Helper_Db::getTableValue(Vikont_Fitment_Helper_Db::getTableName('catalog/product'), 'entity_id', 'type_id="simple" AND sku IN ("' . implode('","', $skus) . '")'); if (!$productId) { // Mage::log(sprintf('ERROR: Unable to find a product: ARI product=%d, fitment=%d, ARI product SKU=%d', $ariProductId, $fitmentId, implode(', ', $skus))); Mage::log(sprintf('ERROR: Unable to find a product: ARI activity=%d, ARI product=%d, fitment=%d, ARI product SKU=%d', $ariActivityId, $ariProductId, $fitmentId, implode(', ', $skus))); } return $productId; }
public function viewAction() { $skuId = $this->getRequest()->getParam('sku'); if (!$skuId) { $this->_redirectReferer(); } try { $productId = Vikont_Fitment_Helper_Db::getTableValue(Vikont_Fitment_Helper_Db::getTableName('catalog/product'), 'entity_id', 'type_id="' . Mage_Catalog_Model_Product_Type::TYPE_SIMPLE . '" AND sku="' . addslashes($skuId) . '"'); $product = Mage::getModel('catalog/product')->load($productId); if ($product->getId()) { $url = $product->getProductUrl(); if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) { $params = $this->getRequest()->getParams(); unset($params['sku']); $params['from'] = 'fitment'; $url .= '?' . http_build_query($params); } $this->getResponse()->setRedirect($url); return; } } catch (Exception $e) { Mage::logException($e); } $this->_redirectReferer(); }