Item.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Quote\Model\ResourceModel\Quote;
  7. use Magento\Framework\Model\ResourceModel\Db\VersionControl\AbstractDb;
  8. /**
  9. * Quote resource model
  10. *
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. */
  13. class Item extends AbstractDb
  14. {
  15. /**
  16. * Main table and field initialization
  17. *
  18. * @return void
  19. */
  20. protected function _construct()
  21. {
  22. $this->_init('quote_item', 'item_id');
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function save(\Magento\Framework\Model\AbstractModel $object)
  28. {
  29. $hasDataChanges = $this->isModified($object);
  30. $object->setIsOptionsSaved(false);
  31. $result = parent::save($object);
  32. if ($hasDataChanges && !$object->isOptionsSaved()) {
  33. $object->saveItemOptions();
  34. }
  35. return $result;
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. protected function prepareDataForUpdate($object)
  41. {
  42. $data = parent::prepareDataForUpdate($object);
  43. if (isset($data['updated_at'])) {
  44. unset($data['updated_at']);
  45. }
  46. return $data;
  47. }
  48. }