Skip to content

Instantly share code, notes, and snippets.

@bluvertigo
Created January 9, 2018 10:15
Show Gist options
  • Save bluvertigo/92abb65be4a64594440cb5f50cc11dd0 to your computer and use it in GitHub Desktop.
Save bluvertigo/92abb65be4a64594440cb5f50cc11dd0 to your computer and use it in GitHub Desktop.
Check if product is new using observer
<?php
class Some_Module_Model_Observer{
protected $isNew = false;
public function beforeSave($observer) {
$product = $observer->getEvent()->getProduct();
if($product->isObjectNew()){
$this->isNew = true;
}
}
public function afterSave($observer) {
$product = $observer->getEvent()->getProduct();
if($this->isNew){
/*Add Logic Here*/
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment