protected function _importRealtimeReindex() { if (Mage::helper("urapidflow")->hasMageFeature("indexer_1.4") && $this->_profile->getData("options/import/reindex_type") == "realtime") { $indexer = Mage::getsingleton("index/indexer"); $pAction = Mage::getmodel("catalog/product_action"); $idxEvent = Mage::getmodel("index/event")->setEntity(Mage_Catalog_Model_Product::ENTITY)->setType(Mage_Index_Model_Event::TYPE_MASS_ACTION)->setDataObject($pAction); $pAction->setWebsiteIds(array(0)); $crAppliedPids = $this->_applyCatalogRules(array_values($this->_skus)); if (!empty($crAppliedPids)) { foreach ($crAppliedPids as $craPid) { $this->_realtimeIdx['catalog_product_price'][$craPid] = true; } } Mage::getresourcesingleton("urapidflow/ProductIndexerPrice")->prepareWebsiteDateTable(); if (!Mage::helper("cataloginventory")->isShowOutOfStock()) { foreach (array("catalog_product_attribute", "catalog_product_price", "tag_summary", "catalog_category_product") as $idxKey) { $this->_realtimeIdx[$idxKey] = $this->_realtimeIdx[$idxKey] + $this->_realtimeIdx['cataloginventory_stock']; } } foreach (array("cataloginventory_stock", "catalog_product_attribute", "catalog_product_price", "tag_summary", "catalog_category_product") as $idxKey) { if (empty($this->_realtimeIdx[$idxKey]) || !$indexer->getProcessByCode($idxKey)) { continue; } $pAction->setProductIds(array_keys($this->_realtimeIdx[$idxKey])); $indexer->getProcessByCode($idxKey)->register($idxEvent)->processEvent($idxEvent); } if (!empty($this->_realtimeIdx['catalogsearch_fulltext'])) { $exPids = array(); if (!empty($this->_realtimeIdx['catalogsearch_fulltext']['full']['C'])) { foreach ($this->_realtimeIdx['catalogsearch_fulltext']['full']['C'] as $wId => $_pIds) { $pIds = array_keys($_pIds); $exPids = array_unique(array_merge($exPids, $pIds)); foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { Mage::getsingleton("catalogsearch/fulltext")->rebuildIndex($sId, $pIds); } } } if (!empty($this->_realtimeIdx['catalogsearch_fulltext']['website']['D'])) { foreach ($this->_realtimeIdx['catalogsearch_fulltext']['website']['D'] as $wId => $_pIds) { $pIds = array_keys($_pIds); foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { Mage::getsingleton("catalogsearch/fulltext")->cleanIndex($sId, $pIds); } } } if (!empty($this->_realtimeIdx['catalogsearch_fulltext']['website']['I'])) { foreach ($this->_realtimeIdx['catalogsearch_fulltext']['website']['I'] as $wId => $_pIds) { $pIds = array_keys($_pIds); if ($pIds = array_diff($pIds, $exPids)) { foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { Mage::getsingleton("catalogsearch/fulltext")->rebuildIndex($sId, $pIds); } } } } } if (!empty($this->_realtimeIdx['catalog_url'])) { $exPids = array(); $urlModel = Mage::getsingleton("catalog/url"); if (!empty($this->_realtimeIdx['catalog_url']['full']['C'])) { foreach ($this->_realtimeIdx['catalog_url']['full']['C'] as $wId => $_pIds) { $pIds = array_keys($_pIds); $exPids = array_unique(array_merge($exPids, $pIds)); foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { foreach ($pIds as $pId) { $urlModel->refreshProductRewrite($pId, $sId); } } } } if (!empty($this->_realtimeIdx['catalog_url']['website']['I'])) { foreach ($this->_realtimeIdx['catalog_url']['website']['I'] as $wId => $_pIds) { $pIds = array_keys($_pIds); if ($pIds = array_diff($pIds, $exPids)) { foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { foreach ($pIds as $pId) { $urlModel->refreshProductRewrite($pId, $sId); } } } } } if (!empty($this->_realtimeIdx['catalog_url']['website']['D'])) { foreach ($this->_realtimeIdx['catalog_url']['website']['D'] as $wId => $_pIds) { $pIds = array_keys($_pIds); foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { foreach ($pIds as $pId) { $urlModel->refreshProductRewrite($pId, $sId); } } } } } if (!empty($this->_realtimeIdx['catalog_product_flat'])) { $idxProdFlat = Mage::getsingleton("catalog/product_flat_indexer"); $exPids = array(); if (!empty($this->_realtimeIdx['catalog_product_flat']['full']['C'])) { foreach ($this->_realtimeIdx['catalog_product_flat']['full']['C'] as $wId => $_pIds) { $pIds = array_keys($_pIds); $exPids = array_unique(array_merge($exPids, $pIds)); foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { $idxProdFlat->updateProduct($pIds, $sId); } } } if (!empty($this->_realtimeIdx['catalog_product_flat']['status'])) { foreach ($this->_realtimeIdx['catalog_product_flat']['status'] as $statusVal => $wData) { if (!empty($wData['C'])) { foreach ($wData['C'] as $wId => $_pIds) { $pIds = array_keys($_pIds); if ($pIds = array_diff($pIds, $exPids)) { foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { $idxProdFlat->updateProductStatus($pIds, $statusVal, $sId); } } } } } } if (!empty($this->_realtimeIdx['catalog_product_flat']['by_attr'])) { foreach ($this->_realtimeIdx['catalog_product_flat']['by_attr'] as $attrCode => $wData) { if (!empty($wData['C'])) { foreach ($wData['C'] as $wId => $_pIds) { $pIds = array_keys($_pIds); if ($pIds = array_diff($pIds, $exPids)) { foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { $idxProdFlat->updateAttribute($attrCode, $sId, $pIds); } } } } } } if (!empty($this->_realtimeIdx['catalog_product_flat']['website']['I'])) { foreach ($this->_realtimeIdx['catalog_product_flat']['website']['I'] as $wId => $_pIds) { $pIds = array_keys($_pIds); if ($pIds = array_diff($pIds, $exPids)) { foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { $idxProdFlat->updateProduct($pIds, $sId); } } } } if (!empty($this->_realtimeIdx['catalog_product_flat']['website']['D'])) { foreach ($this->_realtimeIdx['catalog_product_flat']['website']['D'] as $wId => $_pIds) { $pIds = array_keys($_pIds); foreach ($this->_storesByWebsite[$wId] as $sId => $sData) { $idxProdFlat->removeProduct($pIds, $sId); } } } } } }
protected function _prepareCategories() { $storeId = $this->_profile->getStoreId(); $suffix = Mage::getstoreconfig("catalog/seo/category_url_suffix", $storeId); $suffixLen = strlen($suffix); $eav = Mage::getsingleton("eav/config"); if ($storeId) { $this->_rootCatId = Mage::app()->getStore($storeId)->getGroup()->getRootCategoryId(); } else { $this->_rootCatId = $this->_read->fetchOne("select g.root_category_id from {$this->_t("core/website")} w inner join {$this->_t("core/store_group")} g on g.group_id=w.default_group_id where w.is_default=1"); } $rootPath = $this->_rootCatId ? "1/" . $this->_rootCatId : "1"; $table = $this->_t("catalog/category"); $sql = "select entity_id, path, children_count from {$table} where path='{$rootPath}' or path like '{$rootPath}/%' or entity_id=1"; $rows = $this->_read->fetchAll($sql); if ($rows) { $this->_categories = array(); foreach ($rows as $r) { $this->_categories[$r['entity_id']] = $r; } $sql = $this->_read->quoteInto("select a.attribute_code, v.entity_id, v.value from {$table}_varchar v inner join {$this->_t("eav/attribute")} a on a.attribute_id=v.attribute_id where a.entity_type_id={$this->_entityTypeId} and a.attribute_code in ('url_path') and v.store_id in (0, {$storeId}) and v.entity_id in (?) order by v.store_id desc", array_keys($this->_categories)); $rows = $this->_read->fetchAll($sql); foreach ($rows as $r) { if (empty($this->_categories[$r['entity_id']][$r['attribute_code']])) { $this->_categories[$r['entity_id']][$r['attribute_code']] = $r['value']; } } foreach ($this->_categories as $id => $c) { if (empty($c['url_path'])) { $this->_childrenCount[$id] = $c['children_count']; continue; } $this->_urlPaths[$c['url_path']] = $id; $this->_childrenCount[$c['url_path']] = $c['children_count']; if ($suffix) { $additionalKey = substr($c['url_path'], 0 - $suffixLen) == $suffix ? substr($c['url_path'], 0, strlen($c['url_path']) - $suffixLen) : $c['url_path'] . $suffix; $this->_urlPaths[$additionalKey] = $id; $this->_childrenCount[$additionalKey] = $c['children_count']; } } } }
/** * Get Storebadge Secret * * @return string */ public function getSBSecret() { $secret = Mage::getsingleton('storebadge_ordertracking/config')->getSecret(); return $secret; }
public function syncShippingMethodsAction() { $shipping_failure = ''; $shipping_success = ''; $helper = Mage::helper('magerpsync/connection'); $helper->getSocketConnect(); $userId = Mage::getSingleton('adminhtml/session')->getUserId(); $errorMessage = Mage::getSingleton('adminhtml/session')->getErrorMessage(); if ($userId > 0) { $carriers = Mage::getsingleton("shipping/config")->getAllCarriers(); foreach ($carriers as $code => $method) { if ($method->isTrackingAvailable()) { $response = Mage::getModel('magerpsync/carrier')->syncShippingMethod($code); if ($response) { $shipping_success .= $code . ','; } else { $shipping_failure .= $code . ','; } } } if ($shipping_failure) { Mage::getSingleton('adminhtml/session')->addNotice($this->__("Shipping Methods %s Failed to sync at Odoo!!!", rtrim($shipping_failure, ','))); } elseif ($shipping_success != '') { Mage::getSingleton('adminhtml/session')->addSuccess($this->__("Shipping Methods %s has been Sucessfully Synchronized at Odoo.", rtrim($shipping_success, ','))); } else { Mage::getSingleton('adminhtml/session')->addNotice($this->__("All Shipping Methods are Already Synchronized at Odoo.")); } } else { Mage::getSingleton('adminhtml/session')->addError($errorMessage); } $this->_redirect('*/*/index'); }
/** * Save deal order in custom table * * return void */ public function afterSalesOrderSaved(Varien_Event_Observer $observer) { $event = $observer->getEvent(); /** get Order ID */ $orderId = $event->getOrder()->getId(); /** Load Order Id*/ $order = Mage::getModel('sales/order')->load($orderId); /** Load Customer */ $customer = Mage::getsingleton('customer/customer')->load($order->getCustomerId()); $items = $order->getAllItems(); foreach ($items as $itemId => $item) { $productId = $item->getProductId(); /**Get Product Data */ $obj = Mage::getModel('catalog/product'); $product = $obj->load($productId); /** Get Name */ $productName = $product->getName(); /** Get Price */ $originalPrice = $product->getPrice(); /** Get Special Price */ $specialPrice = $product->getSpecialPrice(); $dealSpecialToDate = $product->getData('special_to_date'); $now = Mage::getModel('core/date')->timestamp(time()); $now = date("Y-m-d" . ' 00:00:00', $now); /** * get email of a customer */ $email = $customer->getEmail(); /** * get Firstname of a customer */ $firstname = $customer->getFirstname(); /** * get lastname of customer */ $lastname = $customer->getLastname(); /** * Checking whether customer loggedin or not */ if (!Mage::getSingleton('customer/session')->isLoggedIn()) { /** * To get Email Id of a customer */ $email = $order->getBillingAddress()->getEmail(); /** * To get Firstname of a customer */ $firstname = $order->getBillingAddress()->getFirstname(); /** * To get Last name of a customer */ $lastname = $order->getBillingAddress()->getLastname(); } /** * check condition if special price is not empty and due date is greater than to current date */ if (!empty($specialPrice) && ($dealSpecialToDate > $now || empty($dealSpecialToDate))) { $model = Mage::getModel('superdeals/dealz'); $model->setCustomerId($firstname . " " . $lastname)->setCustomerMailId($email)->setOrderNo($order->getIncrementId())->setDealId($productName)->setQuantity($item->getQtyToInvoice())->setActualPrice($originalPrice)->setDealPrice($specialPrice)->setPurchaseDate($order->getCreated_at())->setStatus('Pending'); $model->save(); } } }