本文整理汇总了PHP中Varien_Date::now方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Date::now方法的具体用法?PHP Varien_Date::now怎么用?PHP Varien_Date::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Date
的用法示例。
在下文中一共展示了Varien_Date::now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _create
protected function _create(array $data)
{
try {
if (!empty($data)) {
foreach ($data['items'] as $cmspages) {
$identifier = trim($cmspages['identifier']);
$cmsPage = Mage::getModel('cms/page');
$cmsCheck = $cmsPage->getResource()->checkIdentifier($identifier, $cmspages['store_ids']);
if ($cmsCheck) {
$cmsPage->load($cmsCheck);
}
if ($cmsPage->isObjectNew()) {
$cmsPage->setIdentifier($identifier)->setCreationTime(Varien_Date::now());
}
$cmsPage->setUpdateTime(Varien_Date::now())->setStores(array($cmspages['store_ids']))->setIsActive($cmspages['is_active'])->setTitle($cmspages['title'])->setContent($cmspages['content'])->setRootTemplate($cmspages['root_template'])->setMetaKeywords($cmspages['meta_keywords'])->setMetaDescription($cmspages['meta_description'])->setContentHeading($cmspages['content_heading'])->setSortOrder($cmspages['sort_order'])->setLayoutUpdateXml($cmspages['layout_update_xml'])->setCustomTheme($cmspages['custom_theme'])->setCustomRootTemplate($cmspages['custom_root_template'])->setCustomLayoutUpdateXml($cmspages['custom_layout_update_xml'])->setCustomThemeFrom($cmspages['custom_theme_from'])->setCustomThemeTo($cmspages['custom_theme_to'])->save();
}
} else {
$this->_critical('Empty data found');
}
} catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
$this->_critical(sprintf('Invalid attribute "%s": %s', $e->getAttributeCode(), $e->getMessage()), Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
} catch (Mage_Core_Exception $e) {
$this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
} catch (Exception $e) {
$this->_critical(self::RESOURCE_UNKNOWN_ERROR);
}
}
示例2: startAction
/**
* Start edit order initialization
*/
public function startAction()
{
$this->_getSession()->clear();
$orderId = $this->getRequest()->getParam('order_id');
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->getId()) {
$this->_getSession()->setUseOldShippingMethod(true);
$this->_getOrderCreateModel()->initFromOrder($order);
/**
* Lock Order Here
*/
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$condition = array($write->quoteInto('order_id=?', $order->getIncrementId()));
$write->delete('lockorder', $condition);
$sql = "INSERT INTO lockorder values (?,?,?,?,?)";
//insert query
$write->query($sql, array('', $order->getIncrementId(), '1', Varien_Date::now(), ''));
//write to database
/**
* End of Lock Order Here
*/
$this->_redirect('*/*');
} else {
$this->_redirect('*/sales_order/');
}
}
示例3: updateCustomerFromVisitor
/**
* Update Customer from visitor (Customer logged in)
*
* @param Mage_Reports_Model_Product_Index_Abstract $object
* @return Mage_Reports_Model_Resource_Product_Index_Abstract
*/
public function updateCustomerFromVisitor(Mage_Reports_Model_Product_Index_Abstract $object)
{
/**
* Do nothing if customer not logged in
*/
if (!$object->getCustomerId() || !$object->getVisitorId()) {
return $this;
}
$adapter = $this->_getWriteAdapter();
$select = $adapter->select()->from($this->getMainTable())->where('visitor_id = ?', $object->getVisitorId());
$rowSet = $select->query()->fetchAll();
foreach ($rowSet as $row) {
/* We need to determine if there are rows with known
customer for current product.
*/
$select = $adapter->select()->from($this->getMainTable())->where('customer_id = ?', $object->getCustomerId())->where('product_id = ?', $row['product_id']);
$idx = $adapter->fetchRow($select);
if ($idx) {
/* If we are here it means that we have two rows: one with known customer, but second just visitor is set
* One row should be updated with customer_id, second should be deleted
*
*/
$adapter->delete($this->getMainTable(), array('index_id = ?' => $row['index_id']));
$where = array('index_id = ?' => $idx['index_id']);
$data = array('visitor_id' => $object->getVisitorId(), 'store_id' => $object->getStoreId(), 'added_at' => Varien_Date::now());
} else {
$where = array('index_id = ?' => $row['index_id']);
$data = array('customer_id' => $object->getCustomerId(), 'store_id' => $object->getStoreId(), 'added_at' => Varien_Date::now());
}
$adapter->update($this->getMainTable(), $data, $where);
}
return $this;
}
示例4: _create
protected function _create(array $data)
{
try {
if (!empty($data)) {
foreach ($data['items'] as $cmsblocks) {
$storeArray = array();
$storeArray = explode(',', $cmsblocks['store_ids']);
$identifier = trim($cmsblocks['identifier']);
$cmsBlock = Mage::getModel('cms/block');
$collection = Mage::getModel('cms/block')->getCollection()->addStoreFilter($storeArray, false)->addFieldToFilter('identifier', $identifier);
//->toArray();
$collectionData = $collection->getData();
if (isset($collectionData[0]['block_id'])) {
$cmsBlock->load($collectionData[0]['block_id']);
}
if ($cmsBlock->isObjectNew()) {
$cmsBlock->setIdentifier($identifier)->setCreationTime(Varien_Date::now());
}
$cmsBlock->setUpdateTime(Varien_Date::now())->setStores(array($cmsblocks['store_ids']))->setIsActive($cmsblocks['is_active'])->setTitle($cmsblocks['title'])->setContent($cmsblocks['content'])->save();
}
} else {
$this->_critical('Empty data found');
}
} catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
$this->_critical(sprintf('Invalid attribute "%s": %s', $e->getAttributeCode(), $e->getMessage()), Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
} catch (Mage_Core_Exception $e) {
$this->_critical($e->getMessage(), Mage_Api2_Model_Server::HTTP_INTERNAL_ERROR);
} catch (Exception $e) {
$this->_critical(self::RESOURCE_UNKNOWN_ERROR);
}
}
示例5: setDate
protected function setDate()
{
$currentTime = Varien_Date::now();
if ((!$this->getId() || $this->isObjectNew()) && !$this->getCreatedAt()) {
$this->setCreatedAt($currentTime);
}
return $this;
}
示例6: beforeSave
/**
* Set created date
*
* @param Mage_Core_Model_Object $object
* @return Mage_Eav_Model_Entity_Attribute_Backend_Time_Created
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getAttributeCode();
if ($object->isObjectNew() && is_null($object->getData($attributeCode))) {
$object->setData($attributeCode, Varien_Date::now());
}
return $this;
}
示例7: _beforeSave
/**
* If object is new adds creation date
*
* @return NoPro_Bluemoon_Model_Bluemoon
*/
protected function _beforeSave()
{
parent::_beforeSave();
if ($this->isObjectNew()) {
$this->setData('created_at', Varien_Date::now());
}
return $this;
}
示例8: now
/**
* Return the current date in internal format.
*
* @param bool $withoutTime day only flag
*
* @return string
*/
public function now($withoutTime = false)
{
if (method_exists("Varien_Date", "now")) {
return Varien_Date::now($withoutTime);
} else {
$format = $withoutTime ? "Y-m-d" : "Y-m-d H:i:s";
return date($format);
}
}
示例9: _updateDiscountPercents
/**
* Update tax percents for WEEE based on products condition
*
* @param mixed $productCondition
* @return Mage_Weee_Model_Resource_Tax
*/
protected function _updateDiscountPercents($productCondition = null)
{
$now = Varien_Date::toTimestamp(Varien_Date::now());
$adapter = $this->_getWriteAdapter();
$select = $this->_getReadAdapter()->select();
$select->from(array('data' => $this->getTable('catalogrule/rule_product')));
$deleteCondition = '';
if ($productCondition) {
if ($productCondition instanceof Mage_Catalog_Model_Product) {
$select->where('product_id = ?', (int) $productCondition->getId());
$deleteCondition = $adapter->quoteInto('entity_id=?', (int) $productCondition->getId());
} elseif ($productCondition instanceof Mage_Catalog_Model_Product_Condition_Interface) {
$productCondition = $productCondition->getIdsSelect($adapter)->__toString();
$select->where("product_id IN ({$productCondition})");
$deleteCondition = "entity_id IN ({$productCondition})";
} else {
$select->where('product_id = ?', (int) $productCondition);
$deleteCondition = $adapter->quoteInto('entity_id = ?', (int) $productCondition);
}
} else {
$select->where('(from_time <= ? OR from_time = 0)', $now)->where('(to_time >= ? OR to_time = 0)', $now);
}
$adapter->delete($this->getTable('weee/discount'), $deleteCondition);
$select->order(array('data.website_id', 'data.customer_group_id', 'data.product_id', 'data.sort_order'));
$data = $this->_getReadAdapter()->query($select);
$productData = array();
$stops = array();
$prevKey = false;
while ($row = $data->fetch()) {
$key = "{$row['product_id']}-{$row['website_id']}-{$row['customer_group_id']}";
if (isset($stops[$key]) && $stops[$key]) {
continue;
}
if ($prevKey && $prevKey != $key) {
foreach ($productData as $product) {
$adapter->insert($this->getTable('weee/discount'), $product);
}
$productData = array();
}
if ($row['action_operator'] == 'by_percent') {
if (isset($productData[$key])) {
$productData[$key]['value'] -= $productData[$key]['value'] / 100 * $row['action_amount'];
} else {
$productData[$key] = array('entity_id' => $row['product_id'], 'customer_group_id' => $row['customer_group_id'], 'website_id' => $row['website_id'], 'value' => 100 - $row['action_amount']);
}
}
if ($row['action_stop']) {
$stops[$key] = true;
}
$prevKey = $key;
}
foreach ($productData as $product) {
$adapter->insert($this->getTable('weee/discount'), $product);
}
return $this;
}
示例10: _beforeSave
/**
* Processing object before save data
*
* @return Mage_Core_Model_Abstract
*/
protected function _beforeSave()
{
if (!$this->hasTrackCode()) {
$this->_dataSaveAllowed = false;
} else {
$this->setCreatedAt(Varien_Date::now());
$this->setRemoteIp(Mage::helper('core/http')->getRemoteAddr());
}
return parent::_beforeSave();
}
示例11: _prepareDataForSave
/**
* Prepare data for save
*
* @param Mage_Core_Model_Abstract $object
* @return array
*/
protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
{
$currentTime = Varien_Date::now();
if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
$object->setCreatedAt($currentTime);
}
$object->setUpdatedAt($currentTime);
$data = parent::_prepareDataForSave($object);
return $data;
}
示例12: _beforeSave
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
foreach ($this->_serializedAttr as $attrCode) {
if (is_array($object->getData($attrCode))) {
$object->setData($attrCode, serialize($object->getData($attrCode)));
}
}
$now = Varien_Date::now(false);
$object->setUpdatedAt($now);
}
示例13: _initCollection
/**
* Setup the prepared design change collection.
*
* @param int $storeId The current store ID.
* @param string $date The current date.
*
* @return Mage_Core_Model_Resource_Design_Collection
*/
protected function _initCollection($storeId, $date = null)
{
if (!$this->_preparedCollection) {
if (is_null($date)) {
$date = Varien_Date::now();
}
$collection = $this->getCollection()->addStoreFilter($storeId);
$collection->getSelect()->where('enabled = 1')->where('date_from <= ? or date_from IS NULL', $date)->where('date_to >= ? or date_to IS NULL', $date);
$this->_preparedCollection = $collection;
}
return $this->_preparedCollection;
}
示例14: _beforeSave
/**
* Prepare some data before save processing
*
* @param Mage_Core_Model_Abstract $object
*
* @return MatheusGontijo_EasyShippingRules_Model_Resource_Custommethod
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getPricePercentage()) {
$object->setPricePercentage(null);
}
if (!$object->getId()) {
$object->setCreatedAt(Varien_Date::now());
} else {
$object->setUpdatedAt(Varien_Date::now());
}
return $this;
}
示例15: sales_order_creditmemo_refund
/**
*
* @param <type> $observer
* @return <type>
* @desciption After saving credit memo, Relase Lock
*/
public function sales_order_creditmemo_refund($observer)
{
$orderId = Mage::app()->getFrontController()->getRequest()->getParam('order_id');
$order = Mage::getModel('sales/order')->load($orderId);
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$connection->beginTransaction();
$fields = array();
$fields['status'] = '0';
$fields['lock_released'] = Varien_Date::now();
$where = $connection->quoteInto('order_id =?', $order->getIncrementId());
$connection->update('lockorder', $fields, $where);
$connection->commit();
return;
}