当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Index_Model_Process::unlock方法代码示例

本文整理汇总了PHP中Mage_Index_Model_Process::unlock方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Index_Model_Process::unlock方法的具体用法?PHP Mage_Index_Model_Process::unlock怎么用?PHP Mage_Index_Model_Process::unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Index_Model_Process的用法示例。


在下文中一共展示了Mage_Index_Model_Process::unlock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: start

 public function start($count = 0)
 {
     if (!$count) {
         $this->limit = Mage::getStoreConfig('kirchbergerknorr/factfindersync/queue');
     } else {
         $this->limit = $count;
     }
     if ($this->indexProcess->isLocked()) {
         $this->log("Another %s process is running! Aborted", self::PROCESS_ID);
         return false;
     }
     // Set an exclusive lock.
     $this->indexProcess->lockAndBlock();
     $this->log("========================================");
     $timeStart = microtime(true);
     $this->log("Started FactFinderSync");
     $this->insertNewProducts();
     $this->updateImportedProducts();
     $timeEnd = microtime(true);
     $time = $timeEnd - $timeStart;
     $this->log("Finished FactFinderSync limit %s in %s seconds", $this->limit, $time);
     // Remove the lock.
     $this->indexProcess->unlock();
     return true;
 }
开发者ID:kirchbergerknorr,项目名称:FactFinderSync,代码行数:25,代码来源:Sync.php

示例2: testUnlock

 public function testUnlock()
 {
     $this->_processFile = $this->getMock('Mage_Index_Model_Process_File', array('processUnlock'));
     $this->_processFile->expects($this->once())->method('processUnlock');
     $this->_prepareIndexProcess();
     $result = $this->_indexProcess->unlock();
     $this->assertEquals($this->_indexProcess, $result);
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:8,代码来源:ProcessTest.php

示例3: run

 /**
  * Run the Task
  * 
  * IF ANY Job we run fails, due to another processes being run we should
  * gracefully exit and wait our next go!
  * 
  * Also change auto sync to just create a job, and run a single job Queue!
  */
 public function run()
 {
     if ($this->_config()->isLogEnabled()) {
         $this->_config()->dbLog("Cron [Triggered]");
     }
     /**
      * This doesn't exist in 1.3.2!
      */
     $indexProcess = new Mage_Index_Model_Process();
     $indexProcess->setId(self::LOCK_INDEX_ID);
     if ($indexProcess->isLocked()) {
         // Check how old the lock is - unlock after 1hr
         if ($this->_lockIsOld(self::LOCK_INDEX_ID)) {
             $indexProcess->unlock();
         } else {
             $this->_config()->log('MAILUP: cron already running or locked');
             return false;
         }
     }
     $indexProcess->lockAndBlock();
     try {
         require_once dirname(__FILE__) . '/../Helper/Data.php';
         $db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
         $db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
         $syncTableName = Mage::getSingleton('core/resource')->getTableName('mailup/sync');
         $jobsTableName = Mage::getSingleton('core/resource')->getTableName('mailup/job');
         $lastsync = gmdate("Y-m-d H:i:s");
         // reading customers (jobid == 0, their updates)
         $customer_entity_table_name = Mage::getSingleton('core/resource')->getTableName('customer_entity');
         /**
          * Now Handle Jobs we need to Sync, and all customers attached to each job
          */
         foreach (Mage::getModel('mailup/job')->fetchQueuedOrStartedJobsCollection() as $jobModel) {
             /* @var $jobModel MailUp_MailUpSync_Model_Job */
             $job = $jobModel->getData();
             $storeId = isset($job['store_id']) ? $job['store_id'] : NULL;
             // If job is auto-sync and cron is not enabled for the job's site, skip the job
             if ($jobModel->isAutoSync() && !$this->_config()->isCronExportEnabled($storeId)) {
                 $this->_config()->dbLog("Auto-Task skipped as auto-sync disabled for site", $job["id"], $storeId);
                 continue;
             }
             $stmt = $db_write->query("UPDATE {$jobsTableName}\n                    SET status='started', start_datetime='" . gmdate("Y-m-d H:i:s") . "'\n                    WHERE id={$job["id"]}");
             $customers = array();
             $job['mailupNewGroup'] = 0;
             $job['mailupIdList'] = Mage::getStoreConfig('mailup_newsletter/mailup/list', $storeId);
             $job["mailupGroupId"] = $job["mailupgroupid"];
             $job["send_optin_email_to_new_subscribers"] = $job["send_optin"];
             // If group is 0 and there is a default group, set group to this group
             $defaultGroupId = Mage::getStoreConfig('mailup_newsletter/mailup/default_group');
             if ($job["mailupGroupId"] == 0 && $defaultGroupId !== null) {
                 $job["mailupGroupId"] = $defaultGroupId;
             }
             $tmp = Mage::getSingleton('mailup/source_lists');
             $tmp = $tmp->toOptionArray($storeId);
             // pass store id!
             foreach ($tmp as $t) {
                 if ($t["value"] == $job['mailupIdList']) {
                     $job['mailupListGUID'] = $t["guid"];
                     $job["groups"] = $t["groups"];
                     break;
                 }
             }
             unset($tmp);
             unset($t);
             $stmt = $db_read->query("\n                    SELECT ms.*, ce.email\n                    FROM {$syncTableName} ms\n                    JOIN {$customer_entity_table_name} ce\n                        ON (ms.customer_id = ce.entity_id)\n                    WHERE ms.needs_sync=1\n                    AND ms.entity='customer'\n                    AND job_id={$job["id"]}");
             while ($row = $stmt->fetch()) {
                 $customers[] = $row["customer_id"];
             }
             /**
              * Send the Data!
              */
             $returnCode = MailUp_MailUpSync_Helper_Data::generateAndSendCustomers($customers, $job, $storeId);
             /**
              * Check return OK
              */
             if ($returnCode === 0) {
                 $customerCount = count($customers);
                 $db_write->query("\n                        UPDATE {$syncTableName} SET needs_sync=0, last_sync='{$lastsync}'\n                        WHERE job_id = {$job["id"]}\n                        AND entity='customer'");
                 $this->_config()->dbLog("Job Task [update] [Synced] [customer count:{$customerCount}]", $job["id"], $storeId);
                 // finishing the job also
                 $db_write->query("\n                        UPDATE {$jobsTableName} SET status='finished', finish_datetime='" . gmdate("Y-m-d H:i:s") . "'\n                        WHERE id={$job["id"]}");
                 $this->_config()->dbLog("Jobs [Update] [Complete] [{$job["id"]}]", $job["id"], $storeId);
             } else {
                 $stmt = $db_write->query("UPDATE {$jobsTableName} SET status='queued' WHERE id={$job["id"]}");
                 if ($this->_config()->isLogEnabled()) {
                     $this->_config()->dbLog(sprintf("generateAndSendCustomers [ReturnCode] [ERROR] [%d]", $returnCode), $job["id"], $storeId);
                 }
             }
         }
     } catch (Exception $e) {
         // In case of otherwise uncaught error, unlock and re-throw
         $indexProcess->unlock();
//.........这里部分代码省略.........
开发者ID:hanicker,项目名称:mailup-magento,代码行数:101,代码来源:Cron.php

示例4: array

    					// Remove the first line as it's a comment
    					array_shift($taxonomies);
    
    					$values = array();
    					$i = 0;
    
    					foreach ($taxonomies as $taxonomy) {
    						$values[] = "('" . addslashes(trim($taxonomy)) . "')";
    
    						// Process the file in batches
    						if($i++ % 1000 == 0) {
    							$insertValues = implode(',', $values);
    							$insertStoreId = $_eachStoreId;
    							$installer->run("INSERT INTO {$this->getTable('google_taxonomy')} (`taxonomy_name, store_id`) VALUES {$insertValues}, {$insertStoreId};");
    							$values = array();
    						}
    					}
    
    					// Process any remaining values
    					if(count($values)) {
    						$insertValues = implode(',', $values);
    						$installer->run("INSERT INTO {$this->getTable('google_taxonomy')} (`taxonomy_name, store_id`) VALUES {$insertValues}, {$insertStoreId};");
    					}
    				}
        }*/
    // Add a new category attribute to allow setting the taxonomy, to be displayed on the General Information
    // tab underneath the usual core attributes
    $installer->addAttribute('catalog_category', 'google_product_category', array('group' => 'General Information', 'input' => 'select', 'label' => 'Google Product Category', 'source' => 'feedsgenerator/googleproducts_source_taxonomy', 'sort_order' => 15, 'type' => 'int', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE));
    $installer->endSetup();
    $indexProcess->unlock();
}
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:31,代码来源:mysql4-upgrade-1.0-1.2.php

示例5: unlock

 /**
  * Unlock process
  *
  * @return Mage_Index_Model_Process
  */
 public function unlock()
 {
     if (false === $this->getLockInstance()) {
         return parent::unlock();
     }
     $this->getLockInstance()->unlock();
     return $this;
 }
开发者ID:ThomasNegeli,项目名称:Magento-FastIndexer,代码行数:13,代码来源:Process.php


注:本文中的Mage_Index_Model_Process::unlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。