Skip to content

Commit 82fa433

Browse files
author
airbone42
committed
fixed storing of changes in stock
1 parent 5b164f4 commit 82fa433

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

app/code/community/Firegento/AdminLogger/Model/Observer/Model/Save.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,37 @@ private function storeBeforeId($id) {
6767
* @return int
6868
*/
6969
protected function getAction() {
70-
if (isset($this->beforeIds[$this->currentHash]) AND $this->beforeIds[$this->currentHash]) {
70+
if (
71+
// for models which call model_save_before
72+
$this->hadIdAtBefore()
73+
OR
74+
// for models with origData but without model_save_before like Mage_CatalogInventory_Model_Stock_Item
75+
$this->hasOrigData()
76+
) {
7177
return Firegento_AdminLogger_Helper_Data::ACTION_UPDATE;
7278
} else {
7379
return Firegento_AdminLogger_Helper_Data::ACTION_INSERT;
7480
}
7581
}
7682

83+
/**
84+
* @return bool
85+
*/
86+
private function hadIdAtBefore() {
87+
return (
88+
isset($this->beforeIds[$this->currentHash])
89+
AND $this->beforeIds[$this->currentHash]
90+
);
91+
}
92+
93+
/**
94+
* @return bool
95+
*/
96+
private function hasOrigData() {
97+
$data = $this->savedModel->getOrigData();
98+
// unset website_ids as this is even on new entities set for catalog_product models
99+
unset($data['website_ids']);
100+
return (bool)$data;
101+
}
102+
77103
}

app/code/community/Firegento/AdminLogger/etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<fields>
1919
<updated_at />
2020
<update_time />
21+
<low_stock_date />
2122
</fields>
2223
</exclude>
2324
</firegento_adminlogger_config>

0 commit comments

Comments
 (0)