Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from ildelux/master
Browse files Browse the repository at this point in the history
- fixed api call for external_id
  • Loading branch information
ildelux authored Dec 17, 2018
2 parents 9f8c949 + 3a913ed commit 7bd6264
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function _prepareColumns()

public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
return false;
}

protected function _prepareMassaction()
Expand Down
4 changes: 4 additions & 0 deletions app/code/community/Contactlab/Hub/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ protected function _getCustomerAttributeValue($attributeCode, $customer)
{
$value = $customer->getEntityId();
}
elseif($attributeCode == 'email')
{
$value = $customer->getEmail();
}
else
{
$attribute = Mage::getModel('eav/entity_attribute')
Expand Down
37 changes: 12 additions & 25 deletions app/code/community/Contactlab/Hub/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,23 +275,6 @@ protected function _getCustomerDataForHub()
$websiteId = Mage::getModel('core/store')->load($this->getStoreId())->getWebsiteId();
$customer = Mage::getModel("customer/customer")->setWebsiteId($websiteId)->loadByEmail($this->getIdentityEmail());
if ($customer) {
/*
if ($customer->getPrefix()) {
$base->title = $customer->getPrefix();
}
if ($customer->getFirstname()) {
$base->firstName = $customer->getFirstname();
}
if ($customer->getLastname()) {
$base->lastName = $customer->getLastname();
}
if ($customer->getGender()) {
$base->gender = $customer->getGender() == 1 ? 'Male' : 'Female';
}
if ($customer->getDob()) {
$base->dob = date('Y-m-d', strtotime($customer->getDob()));
}
*/
$customerAddressId = $customer->getDefaultBilling();

if (intval($customerAddressId)) {
Expand Down Expand Up @@ -324,10 +307,15 @@ protected function _getCustomerDataForHub()
}
$extraBaseProperties = $this->_helper()->getExtraProperties($customer, 'base');
$base = (object) array_merge( (array)$base, $extraBaseProperties );

$customerData->externalId = $this->_helper()->getExternalId($customer);

}
if (in_array($this->getName(), array('campaignSubscribed', 'campaignUnsubscribed'))) {
if (in_array($this->getName(), array('campaignSubscribed', 'campaignUnsubscribed')))
{
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($this->getIdentityEmail());
if ($subscriber->getId()) {
if ($subscriber->getId())
{
$subcriberObj = new stdClass();
$subcriberObj->id = $this->_helper()->getConfigData('events/campaignName', $this->getStoreId());
$subcriberObj->kind = "DIGITAL_MESSAGE";
Expand All @@ -345,13 +333,12 @@ protected function _getCustomerDataForHub()
}
$subscriptions[] = $subcriberObj;
$base->subscriptions = $subscriptions;
}
}

$externalId = $this->_helper()->getExternalId($customer);
if($externalId)
{
$customerData->externalId = $externalId;
if(!$customerData->externalId)
{
$customerData->externalId = $subscriber->getSubscriberEmail();
}
}
}

$customerData->base = $base;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ protected function _insertCustomers()
}

protected function _insertSubscribers()
{
{
$query = " SELECT ne.customer_id
,ne.store_id
,ne.subscriber_email as email
FROM ".$this->_subscriberTable." as ne
LEFT OUTER JOIN ".$this->_previouscustomersTable." as chp ON ne.subscriber_email = chp.email
WHERE ne.store_id IN (0, ".$this->getStoreId().")
AND ne.customer_id = 0
AND ne.subscriber_status = ".Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED."
AND chp.id IS NULL ";
if($this->_mode == self::PARTIAL_EXPORT)
Expand All @@ -182,9 +183,17 @@ protected function _insertSubscribers()
{
$query .=" LIMIT 0, ". $exportable;
}
}

return $this;
}
$results = $this->_getReadConnection()->fetchAll($query);

foreach ($results as $row)
{
/* CUSTOMER INFORMATIONS */
$query = " INSERT INTO ".$this->_previouscustomersTable." SET ".$this->_buildInsertQuery($row);
//echo var_dump($row);
$this->_getWriteConnection()->query($query, $row);
}
return $this;
}

private function _buildInsertQuery($data)
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Contactlab/Hub/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Contactlab_Hub>
<version>2.1.0</version>
<version>2.2.0</version>
</Contactlab_Hub>
</modules>
<global>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"magento-hackathon/magento-composer-installer": "*"
},
"type": "magento-module",
"version": "2.1.0",
"version": "2.2.0",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down

0 comments on commit 7bd6264

Please sign in to comment.