Example #1
0
 /**
  * Process testimonial data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId() || !$object->getDate()) {
         $object->setDate($this->_date->gmtDate());
     }
     return parent::_beforeSave($object);
 }
Example #2
0
 public function testGmtDate()
 {
     $time = 1403858418;
     $this->localeDate->expects($this->any())->method('date')->with($time)->will($this->returnValue($this->date));
     $this->assertSame(false, $this->dateTime->gmtDate(null, 'tro-lo-lo'));
     $this->assertSame('2014-06-27', $this->dateTime->gmtDate('Y-m-d', $time));
 }
Example #3
0
 /**
  * Update the status of a queue record and check to confirm the exclusive change
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return bool
  */
 public function changeQueueStatusWithLocking(AbstractModel $object)
 {
     /* @var $object \ClassyLlama\AvaTax\Model\Queue */
     $object->setUpdatedAt($this->dateTime->gmtDate());
     $data = $this->prepareDataForUpdate($object);
     $originalQueueStatus = $object->getOrigData(self::QUEUE_STATUS_FIELD_NAME);
     $originalUpdatedAt = $object->getOrigData(self::UPDATED_AT_FIELD_NAME);
     // A conditional update does a read lock on update so we use the condition on the old
     // queue status here to guarantee that nothing else has modified the status for processing
     $condition = array();
     // update only the queue record identified by Id
     $condition[] = $this->getConnection()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
     // only update the record if it is still pending
     $condition[] = $this->getConnection()->quoteInto(self::QUEUE_STATUS_FIELD_NAME . '=?', $originalQueueStatus);
     // only update the record if nothing else has updated it
     if ($originalUpdatedAt === null) {
         $condition[] = self::UPDATED_AT_FIELD_NAME . ' IS NULL';
     } else {
         $condition[] = $this->getConnection()->quoteInto(self::UPDATED_AT_FIELD_NAME . '=?', $originalUpdatedAt);
     }
     // update the record and get the number of affected records
     $affectedRowCount = $this->getConnection()->update($this->getMainTable(), $data, $condition);
     $result = false;
     if ($affectedRowCount > 0) {
         $object->setHasDataChanges(false);
         $result = true;
     }
     return $result;
 }
 /**
  * Before saving the object, add the created or updated times
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
Example #5
0
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     $object->setUpdatedAt($this->_date->gmtDate());
     return $this;
 }
Example #6
0
 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->isValidNewsblock($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Please fill out newsblock fields.'));
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
Example #7
0
 /**
  * Perform operations before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->getIsUniqueBlockToStores($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('A block identifier with the same properties already exists in the selected store.'));
     }
     if (!$object->getId()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return $this;
 }
Example #8
0
 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->isValidPostUrlKey($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The post URL key contains capital letters or disallowed symbols.'));
     }
     if ($this->isNumericPostUrlKey($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The post URL key cannot be made of only numbers.'));
     }
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
Example #9
0
 /**
  * before save callback
  *
  * @param AbstractModel|\Sample\News\Model\Author $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     foreach (['dob'] as $field) {
         $value = !$object->getData($field) ? null : $object->getData($field);
         $object->setData($field, $this->dateTime->formatDate($value));
     }
     $object->setUpdatedAt($this->date->gmtDate());
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->date->gmtDate());
     }
     $urlKey = $object->getData('url_key');
     if ($urlKey == '') {
         $urlKey = $object->getName();
     }
     $urlKey = $object->formatUrlKey($urlKey);
     $object->setUrlKey($urlKey);
     $validKey = false;
     while (!$validKey) {
         if ($this->getIsUniqueAuthorToStores($object)) {
             $validKey = true;
         } else {
             $parts = explode('-', $urlKey);
             $last = $parts[count($parts) - 1];
             if (!is_numeric($last)) {
                 $urlKey = $urlKey . '-1';
             } else {
                 $suffix = '-' . ($last + 1);
                 unset($parts[count($parts) - 1]);
                 $urlKey = implode('-', $parts) . $suffix;
             }
             $object->setData('url_key', $urlKey);
         }
     }
     return parent::_beforeSave($object);
 }
Example #10
0
 /**
  * Process page data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /*
      * For two attributes which represent timestamp data in DB
      * we should make converting such as:
      * If they are empty we need to convert them into DB
      * type NULL so in DB they will be empty and not some default value
      */
     foreach (array('custom_theme_from', 'custom_theme_to') as $field) {
         $value = !$object->getData($field) ? null : $object->getData($field);
         $object->setData($field, $this->dateTime->formatDate($value));
     }
     if (!$object->getData('identifier')) {
         $object->setData('identifier', $this->filter->translitUrl($object->getData('title')));
     }
     if (!$this->getIsUniquePageToStores($object)) {
         throw new \Magento\Framework\Model\Exception(__('A page URL key for specified store already exists.'));
     }
     if (!$this->isValidPageIdentifier($object)) {
         throw new \Magento\Framework\Model\Exception(__('The page URL key contains capital letters or disallowed symbols.'));
     }
     if ($this->isNumericPageIdentifier($object)) {
         throw new \Magento\Framework\Model\Exception(__('The page URL key cannot be made of only numbers.'));
     }
     // modify create / update dates
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
Example #11
0
 /**
  * Finish queue: set status SENT and update finish date
  *
  * @return $this
  */
 protected function _finishQueue()
 {
     $this->setQueueFinishAt($this->_date->gmtDate());
     $this->setQueueStatus(self::STATUS_SENT);
     $this->save();
     return $this;
 }
 /**
  * Check if post identifier exist for specific store
  * return post id if post exists
  *
  * @param string $identifier
  * @param int $storeId
  * @return int
  */
 protected function _getLoadByIdentifierSelect($identifier, $store, $isActive = null)
 {
     $select = $this->getConnection()->select()->from(['cp' => $this->getMainTable()])->join(['cps' => $this->getTable('magefan_blog_post_store')], 'cp.post_id = cps.post_id', [])->where('cp.identifier = ?', $identifier)->where('cps.store_id IN (?)', $store);
     if (!is_null($isActive)) {
         $select->where('cp.is_active = ?', $isActive)->where('cp.publish_time <= ?', $this->_date->gmtDate());
     }
     return $select;
 }
Example #13
0
 /**
  * @param \Magento\Framework\Model\AbstractModel $object
  *
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$this->isSlugEmpty($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Something wrong with slug'));
     }
     if (!$this->isSlugValid($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('This post slug contain disallowed symbols.'));
     }
     if ($this->isSlugNumeric($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Post slug can\'t be made of only numbers'));
     }
     if ($object->isObjectNew() && !$object->hasCreatedAt()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     $object->setUpdatedAt($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
 /**
  * Saves flag
  *
  * @param string $code
  * @param mixed $value
  * @return $this
  */
 protected function _setFlagData($code, $value = null)
 {
     $this->_getFlag()->setReportFlagCode($code)->unsetData()->loadSelf();
     if ($value !== null) {
         $this->_getFlag()->setFlagData($value);
     }
     // touch last_update
     $this->_getFlag()->setLastUpdate($this->dateTime->gmtDate());
     $this->_getFlag()->save();
     return $this;
 }
Example #15
0
 /**
  * Process form data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \AddictedToMagento\DynamicForms\Model\Form $object */
     if (!$this->isValidFormIdentifier($object)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The Form Identifier contains capital letters or disallowed symbols.'));
     }
     if ($object->isObjectNew() && !$object->hasData(FormInterface::CREATION_TIME)) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
 /**
  * Set imported in bulk query.
  *
  * @param $ids
  */
 public function _setImported($ids)
 {
     try {
         $coreResource = $this->resource;
         $write = $coreResource->getConnection('core_write');
         $tableName = $coreResource->getTableName('email_review');
         $ids = implode(', ', $ids);
         $nowDate = $this->coreDate->gmtDate();
         $write->update($tableName, ['review_imported' => 1, 'updated_at' => $nowDate], "review_id IN ({$ids})");
     } catch (\Exception $e) {
         $this->helper->debug((string) $e, []);
     }
 }
Example #17
0
 /**
  * Update items low stock date basing on their quantities and config settings
  *
  * @param int|string $website
  * @return void
  */
 public function updateLowStockDate($website)
 {
     $websiteId = $this->storeManager->getWebsite($website)->getId();
     $this->_initConfig();
     $connection = $this->getConnection();
     $condition = $connection->quoteInto('(use_config_notify_stock_qty = 1 AND qty < ?)', $this->_configNotifyStockQty) . ' OR (use_config_notify_stock_qty = 0 AND qty < notify_stock_qty)';
     $currentDbTime = $connection->quoteInto('?', $this->dateTime->gmtDate());
     $conditionalDate = $connection->getCheckSql($condition, $currentDbTime, 'NULL');
     $value = ['low_stock_date' => new \Zend_Db_Expr($conditionalDate)];
     $select = $connection->select()->from($this->getTable('catalog_product_entity'), 'entity_id')->where('type_id IN(?)', $this->_configTypeIds);
     $where = sprintf('website_id = %1$d' . ' AND ((use_config_manage_stock = 1 AND 1 = %2$d) OR (use_config_manage_stock = 0 AND manage_stock = 1))' . ' AND product_id IN (%3$s)', $websiteId, $this->_isConfigManageStock, $select->assemble());
     $connection->update($this->getTable('cataloginventory_stock_item'), $value, $where);
 }
Example #18
0
 /**
  * Updates data when subscriber received
  *
  * @param \Magento\Newsletter\Model\Subscriber $subscriber
  * @param \Magento\Newsletter\Model\Queue $queue
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function received(\Magento\Newsletter\Model\Subscriber $subscriber, \Magento\Newsletter\Model\Queue $queue)
 {
     $this->connection->beginTransaction();
     try {
         $data['letter_sent_at'] = $this->_date->gmtDate();
         $this->connection->update($this->_subscriberLinkTable, $data, ['subscriber_id = ?' => $subscriber->getId(), 'queue_id = ?' => $queue->getId()]);
         $this->connection->commit();
     } catch (\Exception $e) {
         $this->connection->rollBack();
         throw new \Magento\Framework\Exception\LocalizedException(__('We cannot mark as received subscriber.'));
     }
     return $this;
 }
Example #19
0
 /**
  * Perform actions before object save
  *
  * @param AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     if (!$object->getId()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     if ($object->hasData('stores') && is_array($object->getStores())) {
         $stores = $object->getStores();
         $stores[] = 0;
         $object->setStores($stores);
     } elseif ($object->hasData('stores')) {
         $object->setStores([$object->getStores(), 0]);
     }
     return $this;
 }
Example #20
0
 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($this->checkCodeUsage($object)) {
         throw new \Magento\Framework\Model\Exception(__('Duplicate template code'));
     }
     if (!$object->hasTemplateActual()) {
         $object->setTemplateActual(1);
     }
     if (!$object->hasAddedAt()) {
         $object->setAddedAt($this->_date->gmtDate());
     }
     $object->setModifiedAt($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
Example #21
0
 /**
  * Check required data
  *
  * @return $this
  */
 public function beforeSave()
 {
     parent::beforeSave();
     // validate required item data
     $this->validate();
     // set current store id if it is not defined
     if (is_null($this->getStoreId())) {
         $this->setStoreId($this->_storeManager->getStore()->getId());
     }
     // set current date if added at data is not defined
     if (is_null($this->getAddedAt())) {
         $this->setAddedAt($this->_date->gmtDate());
     }
     return $this;
 }
 /**
  * @param      $ids
  * @param bool $modified
  */
 public function setImported($ids, $modified = false)
 {
     try {
         $coreResource = $this->resource;
         $write = $coreResource->getConnection('core_write');
         $tableName = $coreResource->getTableName('email_wishlist');
         $ids = implode(', ', $ids);
         $now = $this->datetime->gmtDate();
         //mark imported modified wishlists
         if ($modified) {
             $write->update($tableName, ['wishlist_modified' => 'null', 'updated_at' => $now], "wishlist_id IN ({$ids})");
         } else {
             $write->update($tableName, ['wishlist_imported' => 1, 'updated_at' => $now], "wishlist_id IN ({$ids})");
         }
     } catch (\Exception $e) {
         $this->helper->debug((string) $e, []);
     }
 }
 /**
  * @param \Magento\Sales\Model\Spi\InvoiceResourceInterface $subject
  * @param \Closure $proceed
  *
  *        I include both the extended AbstractModel and implemented Interface here for the IDE's benefit
  * @param \Magento\Framework\Model\AbstractModel|\Magento\Sales\Api\Data\InvoiceInterface $entity
  * @return \Magento\Sales\Model\Spi\InvoiceResourceInterface
  * @throws \Magento\Framework\Exception\CouldNotSaveException
  */
 public function aroundSave(InvoiceResourceInterface $subject, \Closure $proceed, AbstractModel $entity)
 {
     // Check to see if this is a newly created entity and store the determination for later evaluation after
     // the entity is saved via plugin closure. After the entity is saved it will not be listed as new any longer.
     $isObjectNew = $entity->isObjectNew();
     // Save AvaTax extension attributes
     if ($this->avaTaxConfig->isModuleEnabled($entity->getStoreId())) {
         // check to see if any extension attributes exist and set them on the model for saving to the db
         $extensionAttributes = $entity->getExtensionAttributes();
         if ($extensionAttributes && $extensionAttributes->getAvataxIsUnbalanced() !== null) {
             $entity->setData('avatax_is_unbalanced', $extensionAttributes->getAvataxIsUnbalanced());
         }
         if ($extensionAttributes && $extensionAttributes->getBaseAvataxTaxAmount() !== null) {
             $entity->setData('base_avatax_tax_amount', $extensionAttributes->getBaseAvataxTaxAmount());
         }
         // Updating a field to trigger a change to the record when avatax_is_unbalanced and base_avatax_tax_amount
         // are both false or 0 which evaluate the same as null in the isModified check
         if ($extensionAttributes && ($extensionAttributes->getAvataxIsUnbalanced() !== null && ($entity->getOrigData('avatax_is_unbalanced') === null || $extensionAttributes->getAvataxIsUnbalanced() != $entity->getOrigData('avatax_is_unbalanced')) || $extensionAttributes->getBaseAvataxTaxAmount() !== null && ($entity->getOrigData('base_avatax_tax_amount') === null || $extensionAttributes->getBaseAvataxTaxAmount() != $entity->getOrigData('base_avatax_tax_amount')))) {
             $entity->setUpdatedAt($this->dateTime->gmtDate());
         }
     }
     /** @var \Magento\Sales\Model\Spi\InvoiceResourceInterface $resultEntity */
     $resultEntity = $proceed($entity);
     /** @var \Magento\Sales\Model\Order $order */
     $order = $entity->getOrder();
     $isVirtual = $order->getIsVirtual();
     $address = $isVirtual ? $entity->getBillingAddress() : $entity->getShippingAddress();
     $storeId = $entity->getStoreId();
     // Queue the entity to be sent to AvaTax
     if ($this->avaTaxConfig->isModuleEnabled($entity->getStoreId()) && $this->avaTaxConfig->getTaxMode($entity->getStoreId()) == Config::TAX_MODE_ESTIMATE_AND_SUBMIT && $this->avaTaxConfig->isAddressTaxable($address, $storeId)) {
         // Add this entity to the avatax processing queue if this is a new entity
         if ($isObjectNew) {
             /** @var Queue $queue */
             $queue = $this->queueFactory->create();
             $queue->build($entity->getStoreId(), Queue::ENTITY_TYPE_CODE_INVOICE, $entity->getEntityId(), $entity->getIncrementId(), Queue::QUEUE_STATUS_PENDING);
             $queue->save();
             $this->avaTaxLogger->debug(__('Added entity to the queue'), ['queue_id' => $queue->getId(), 'entity_type_code' => Queue::ENTITY_TYPE_CODE_INVOICE, 'entity_id' => $entity->getEntityId()]);
         }
     }
     return $resultEntity;
 }
Example #24
0
 /**
  * Saving information about quote
  *
  * @param   \Magento\Log\Model\Visitor $visitor
  * @return  \Magento\Log\Model\Resource\Visitor
  */
 protected function _saveQuoteInfo($visitor)
 {
     $adapter = $this->_getWriteAdapter();
     if ($visitor->getDoQuoteCreate()) {
         $data = new \Magento\Framework\Object(array('quote_id' => (int) $visitor->getQuoteId(), 'visitor_id' => (int) $visitor->getId(), 'created_at' => $this->_date->gmtDate()));
         $bind = $this->_prepareDataForTable($data, $this->getTable('log_quote'));
         $adapter->insert($this->getTable('log_quote'), $bind);
         $visitor->setDoQuoteCreate(false);
     }
     if ($visitor->getDoQuoteDestroy()) {
         /**
          * We have delete quote from log because if original quote was
          * deleted and Mysql restarted we will get key duplication error
          */
         $condition = array('quote_id = ?' => (int) $visitor->getQuoteId());
         $adapter->delete($this->getTable('log_quote'), $condition);
         $visitor->setDoQuoteDestroy(false);
         $visitor->setQuoteId(null);
     }
     return $this;
 }
 /**
  * @inheritdoc
  */
 public function save(\Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem)
 {
     try {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $this->productFactory->create();
         $product->load($stockItem->getProductId());
         if (!$product->getId()) {
             return $stockItem;
         }
         $typeId = $product->getTypeId() ?: $product->getTypeInstance()->getTypeId();
         $isQty = $this->stockConfiguration->isQty($typeId);
         if ($isQty) {
             $isInStock = $this->stockStateProvider->verifyStock($stockItem);
             if ($stockItem->getManageStock() && !$isInStock) {
                 $stockItem->setIsInStock(false)->setStockStatusChangedAutomaticallyFlag(true);
             }
             // if qty is below notify qty, update the low stock date to today date otherwise set null
             $stockItem->setLowStockDate(null);
             if ($this->stockStateProvider->verifyNotification($stockItem)) {
                 $stockItem->setLowStockDate($this->dateTime->gmtDate());
             }
             $stockItem->setStockStatusChangedAuto(0);
             if ($stockItem->hasStockStatusChangedAutomaticallyFlag()) {
                 $stockItem->setStockStatusChangedAuto((int) $stockItem->getStockStatusChangedAutomaticallyFlag());
             }
         } else {
             $stockItem->setQty(0);
         }
         $stockItem->setWebsiteId($stockItem->getWebsiteId());
         $stockItem->setStockId($stockItem->getStockId());
         $this->resource->save($stockItem);
         $this->indexProcessor->reindexRow($stockItem->getProductId());
     } catch (\Exception $exception) {
         throw new CouldNotSaveException(__($exception->getMessage()));
     }
     return $stockItem;
 }
Example #26
0
 /**
  * Set date of last update
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Magento\Framework\Model\Resource\Db\AbstractDb
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $object->setUpdatedAt($this->dateTime->formatDate($this->_coreDate->gmtDate()));
     return parent::_beforeSave($object);
 }
Example #27
0
 /**
  * Generate XML file
  *
  * @see http://www.sitemaps.org/protocol.html
  *
  * @return $this
  */
 public function generateXml()
 {
     $this->_initSitemapItems();
     /** @var $sitemapItem \Magento\Framework\Object */
     foreach ($this->_sitemapItems as $sitemapItem) {
         $changefreq = $sitemapItem->getChangefreq();
         $priority = $sitemapItem->getPriority();
         foreach ($sitemapItem->getCollection() as $item) {
             $xml = $this->_getSitemapRow($item->getUrl(), $item->getUpdatedAt(), $changefreq, $priority, $item->getImages());
             if ($this->_isSplitRequired($xml) && $this->_sitemapIncrement > 0) {
                 $this->_finalizeSitemap();
             }
             if (!$this->_fileSize) {
                 $this->_createSitemap();
             }
             $this->_writeSitemapRow($xml);
             // Increase counters
             $this->_lineCount++;
             $this->_fileSize += strlen($xml);
         }
     }
     $this->_finalizeSitemap();
     if ($this->_sitemapIncrement == 1) {
         // In case when only one increment file was created use it as default sitemap
         $path = rtrim($this->getSitemapPath(), '/') . '/' . $this->_getCurrentSitemapFilename($this->_sitemapIncrement);
         $destination = rtrim($this->getSitemapPath(), '/') . '/' . $this->getSitemapFilename();
         $this->_directory->renameFile($path, $destination);
     } else {
         // Otherwise create index file with list of generated sitemaps
         $this->_createSitemapIndex();
     }
     // Push sitemap to robots.txt
     if ($this->_isEnabledSubmissionRobots()) {
         $this->_addSitemapToRobotsTxt($this->getSitemapFilename());
     }
     $this->setSitemapTime($this->_dateModel->gmtDate('Y-m-d H:i:s'));
     $this->save();
     return $this;
 }
Example #28
0
 /**
  * Delete attempts with expired in update_at time
  *
  * @return void
  */
 public function deleteOldAttempts()
 {
     $this->getConnection()->delete($this->getMainTable(), ['updated_at < ?' => $this->_coreDate->gmtDate(null, time() - 60 * 30)]);
 }
Example #29
0
 /**
  * Set date of last update for wishlist
  *
  * @return $this
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     $this->setUpdatedAt($this->_date->gmtDate());
     return $this;
 }
Example #30
0
 /**
  * Set date of last update for wishlist
  *
  * @return $this
  */
 public function beforeSave()
 {
     parent::beforeSave();
     $this->setUpdatedAt($this->_date->gmtDate());
     return $this;
 }