-
Notifications
You must be signed in to change notification settings - Fork 64
[A] Adding process schedulized of syncronization #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
return; | ||
|
||
$user = null; | ||
//$customer = $event->getCustomer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it will be removed
* Created by PhpStorm. | ||
* User: o5k4r1n | ||
* Date: 29-05-18 | ||
* Time: 10:44 AM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this comment block.
$user = null; | ||
//$customer = $event->getCustomer(); | ||
$email = $customer->getEmail(); | ||
$orig_email = $customer->getOrigData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this was based from https://github.com/zendesk/magento_extension/blob/master/src/app/code/community/Zendesk/Zendesk/Model/Observer.php#L108 , but moving forward please use camelCase for variable names, to follow the rest of the code.
{ | ||
Mage::getModel('zendesk/api_users')->create($info); | ||
} | ||
} No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a newline at the end of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be added
* User: o5k4r1n | ||
* Date: 25-05-18 | ||
* Time: 05:10 PM | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this comment block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it will be removed.
$zendesk_id = $customer_data['id']; | ||
$customer->setZendeskId($zendesk_id); | ||
$customer->save(); | ||
//Zend_Debug::dump($customer_data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it will be removed.
} | ||
return $user; | ||
} | ||
public function syncData($info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From this PR - this function isn't used outside this class. If it's only used here, then let's set it to private
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, setting to private.
$email = $customer->getEmail(); | ||
$orig_email = $customer->getOrigData(); | ||
$orig_email = $orig_email['email']; | ||
echo "correo: ".$email; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this debug code? if so, please remove thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it was a debug code, Dropping now
public function syncronize(){ | ||
Mage::log('Cron Working', null, 'cron.log', true); | ||
$customers = Mage::getModel('customer/customer') | ||
->getCollection()->setPageSize(90)->setCurPage(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would happen if a timeout is reached and not all customers have finished syncing? On the next cron run would the sync start from the beginning of the collection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an timeout is reached the syncronization will be made only with customers that doesn't have a zendesk_id (null), if the process is interrupted by any reason, then the syncronization will begin then with the first customer found with no zendesk_id. (zendesk_id = null)
It will not be necessary to start from zero this time.
If the process is interrupted will start again in 10 minutes (for example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nitpicks, almost there though 👍
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, | ||
'note' => '', | ||
)); | ||
$installer->endSetup();*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comments
|
||
} | ||
} | ||
} No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line at EOF.
} | ||
return $user; | ||
} | ||
private function syncData($info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line before function.
Hi @joseconsador changes are made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
In order to avoid interrumption of syncronization it have been improved with syncronization scheduled, per 13 minutes it will syncronized 90 customers to zendesk