/** * Insert data (Step 2) * * @param Pimgento_Core_Model_Task $task * * @return bool * @throws Exception */ public function insertData($task) { $file = $task->getFile(); $lines = $this->getRequest()->insertDataFromFile($this->getCode(), $file); if (!$lines) { $task->error(Mage::helper('pimgento_asset')->__('No data to insert, verify the file is not empty or CSV configuration is correct')); } $task->setMessage(Mage::helper('pimgento_asset')->__('%s lines found', $lines)); return true; }
/** * Reindex (Step 18) * * @param Pimgento_Core_Model_Task $task * * @return bool */ public function reindex($task) { if (!$this->getConfig('reindex')) { $task->setMessage(Mage::helper('pimgento_product')->__('Reindex is disabled')); return false; } /* @var $indexer Mage_Index_Model_Indexer */ $indexer = Mage::getSingleton('index/indexer'); Mage::dispatchEvent('shell_reindex_init_process'); if ($this->isEnterprise()) { $processes = array('catalog_product_flat', 'cataloginventory_stock', 'catalog_product_price', 'catalog_url_product', 'url_redirect', 'catalog_category_product', 'catalogsearch_fulltext', 'catalog_product_attribute'); } else { $processes = array('catalog_product_attribute', 'catalog_product_flat', 'catalog_product_price', 'catalog_url', 'catalog_category_product', 'catalogsearch_fulltext', 'cataloginventory_stock'); } foreach ($processes as $code) { $process = $indexer->getProcessByCode($code); if ($process) { $process->reindexEverything(); Mage::dispatchEvent($code . '_shell_reindex_after'); } } Mage::dispatchEvent('shell_reindex_finalize_process'); return true; }
/** * Check required columns * * @param array $columns * @param Pimgento_Core_Model_Task $task * * @return bool */ protected function columnsRequired($columns, $task) { foreach ($columns as $column) { if (!$this->columnExists($column)) { $task->setMessage(Mage::helper('pimgento_product')->__('Column %s not found, step ignored', $column)); return false; } } return true; }
/** * Reindex (Step 8) * * @param Pimgento_Core_Model_Task $task * * @return bool */ public function reindex($task) { if (!$this->getConfig('reindex')) { $task->setMessage(Mage::helper('pimgento_position')->__('Reindex is disabled')); return false; } /* @var $indexer Mage_Index_Model_Indexer */ $indexer = Mage::getSingleton('index/indexer'); Mage::dispatchEvent('shell_reindex_init_process'); $processes = array('catalog_category_product'); foreach ($processes as $code) { $process = $indexer->getProcessByCode($code); if ($process) { $process->reindexEverything(); Mage::dispatchEvent($code . '_shell_reindex_after'); } } Mage::dispatchEvent('shell_reindex_finalize_process'); return true; }
/** * Init default Group (Step 5) * * @param Pimgento_Core_Model_Task $task * * @return bool */ public function initDefaultGroup($task) { $resource = $this->getResource(); $adapter = $this->getAdapter(); $family = $adapter->select()->from($this->getTable(), array('entity_id')); $query = $adapter->query($family); $count = 0; while ($row = $query->fetch()) { $exist = $adapter->fetchOne($adapter->select()->from($resource->getTable('eav/attribute_group'), array($this->_zde(1)))->where('attribute_set_id = ?', $row['entity_id'])->limit(1)); if (!$exist) { $set = Mage::getModel('eav/entity_attribute_set')->load($row['entity_id']); if ($set->hasData()) { $set->initFromSkeleton(4)->save(); $count++; } } } $task->setMessage(Mage::helper('pimgento_attribute')->__('%s family(ies) initialized', $count)); return true; }
/** * Flush catalog image cache (Step 8) * * @param Pimgento_Core_Model_Task $task * * @return bool */ public function cleanImage($task) { if (!Mage::getStoreConfig('pimdata/image/cache')) { $task->setMessage(Mage::helper('pimgento_image')->__('Cache flushing is disabled')); return false; } Mage::getModel('catalog/product_image')->clearCache(); Mage::dispatchEvent('clean_catalog_images_cache_after'); return true; }