Magento always creates new entriesCron job always “missed”Magento2 2.1.5 Cronjob doesn't get executed. ID always 0Cron status is always missed in Magento 1.9Cron job creates loads of records in databaseCustom cron job status always pendingcataloginventory_stock_status randomly has missing entriesMagento 2.3 Can't view module's front end page output?What creates references? I've been unable to find the source of a broken referenceMagento2: Order summary always expandedCron Job status always missed/ not running Magento 2
Why don’t airliners have temporary liveries?
Company did not petition for visa in a timely manner. Is asking me to work from overseas, but wants me to take a paycut
How do I write "Show, Don't Tell" as a person with Asperger Syndrome?
Argon vs nitrogen for preserving wine
Is it possible to 'live off the sea'
How did students remember what to practise between lessons without any sheet music?
Avoiding cliches when writing gods
Inconsistent behavior of compiler optimization of unused string
Taxi Services at Didcot
Can anyone identify this tank?
Why does the Schrödinger equation work so well for the hydrogen atom despite the relativistic boundary at the nucleus?
Turing patterns
How does an ordinary object become radioactive?
Russian equivalents of "no love lost"
Was the Tamarian language in "Darmok" inspired by Jack Vance's "The Asutra"?
What are the peak hours for public transportation in Paris?
How powerful is a "Breathe Air" spell?
What is the advantage of carrying a tripod and ND-filters when you could use image stacking instead?
Can the poison from Kingsmen be concocted?
Different pedals/effects for low strings/notes than high
Did the ending really happen in Baby Driver?
Where does "0 packages can be updated." come from?
When did Linux kernel become libre software?
How would a aircraft visually signal in distress?
Magento always creates new entries
Cron job always “missed”Magento2 2.1.5 Cronjob doesn't get executed. ID always 0Cron status is always missed in Magento 1.9Cron job creates loads of records in databaseCustom cron job status always pendingcataloginventory_stock_status randomly has missing entriesMagento 2.3 Can't view module's front end page output?What creates references? I've been unable to find the source of a broken referenceMagento2: Order summary always expandedCron Job status always missed/ not running Magento 2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a little problem. I am currently working on an synchronize job for cron.
The sync function just gets the newest elements from an api and updates in the Magento db. The Magento version is: 2.3.1 .
Here is the function:
public function synchronize()
$writer = new Stream(BP . '/var/log/cron.log');
$logger = new Logger();
$logger->addWriter($writer);
$login = $this->login();
$dateTimestamp = $this->getLatestDate('/tmp/marketsSync.txt');
$items = $this->getNewestItems($dateTimestamp, $login);
foreach ($items as $item)
$srcItem = $this->_marketFactory->create();
$srcItem->setContent($item);
$marketCollection = $this->_marketCollectionFactory->create();
$marketCollection
->addFieldToSelect('*')
->addFieldToFilter('id_location', ['eq' => $srcItem->getData('id_location')])
->load();
$logger->info('found? :'. $marketCollection->getSize());
if ($marketCollection->getSize())
$tgtItem = $marketCollection->getFirstItem();
$srcTime = strtotime($srcItem->getData('date_upd'));
$tgtTime = strtotime($tgtItem->getData('date_upd'));
if ($srcTime > $tgtTime)
$this->updateElement($tgtItem, $srcItem);
else
$logger->info('create');
$this->createElement($srcItem, $marketCollection);
$this->setLatestDate('/tmp/marketsSync.txt', date("Y-m-d H:i:s") );
public function createElement(Synchronizable $obj)
$item = $this->_marketFactory->create();
$item->setContent($obj->getData());
$item = $item->save();
public function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj)
$writer = new Stream(BP . '/var/log/cron.log');
$logger = new Logger();
$logger->addWriter($writer);
$tgtObj->setContent($srcObj->getData());
$logger->info($tgtObj->getData());
$tgtObj->save();
I've got the Object to update from the marketCollection via getFirstItem(). Now in the updateElement() function i use the the api data to update the object with
$tgtObj->setContent($srcObj->getData());
This function is just a foreach loop:
public function setContent($content)
foreach ($content AS $key => $value)
$this->setData($key, $value);
I know that this method is already deprecated, but why does save allways create a new entry? (it creates the same data but with a new id)
magento2.3 cron
add a comment |
I have a little problem. I am currently working on an synchronize job for cron.
The sync function just gets the newest elements from an api and updates in the Magento db. The Magento version is: 2.3.1 .
Here is the function:
public function synchronize()
$writer = new Stream(BP . '/var/log/cron.log');
$logger = new Logger();
$logger->addWriter($writer);
$login = $this->login();
$dateTimestamp = $this->getLatestDate('/tmp/marketsSync.txt');
$items = $this->getNewestItems($dateTimestamp, $login);
foreach ($items as $item)
$srcItem = $this->_marketFactory->create();
$srcItem->setContent($item);
$marketCollection = $this->_marketCollectionFactory->create();
$marketCollection
->addFieldToSelect('*')
->addFieldToFilter('id_location', ['eq' => $srcItem->getData('id_location')])
->load();
$logger->info('found? :'. $marketCollection->getSize());
if ($marketCollection->getSize())
$tgtItem = $marketCollection->getFirstItem();
$srcTime = strtotime($srcItem->getData('date_upd'));
$tgtTime = strtotime($tgtItem->getData('date_upd'));
if ($srcTime > $tgtTime)
$this->updateElement($tgtItem, $srcItem);
else
$logger->info('create');
$this->createElement($srcItem, $marketCollection);
$this->setLatestDate('/tmp/marketsSync.txt', date("Y-m-d H:i:s") );
public function createElement(Synchronizable $obj)
$item = $this->_marketFactory->create();
$item->setContent($obj->getData());
$item = $item->save();
public function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj)
$writer = new Stream(BP . '/var/log/cron.log');
$logger = new Logger();
$logger->addWriter($writer);
$tgtObj->setContent($srcObj->getData());
$logger->info($tgtObj->getData());
$tgtObj->save();
I've got the Object to update from the marketCollection via getFirstItem(). Now in the updateElement() function i use the the api data to update the object with
$tgtObj->setContent($srcObj->getData());
This function is just a foreach loop:
public function setContent($content)
foreach ($content AS $key => $value)
$this->setData($key, $value);
I know that this method is already deprecated, but why does save allways create a new entry? (it creates the same data but with a new id)
magento2.3 cron
At ` $this->updateElement($tgtItem, $srcItem);` ,$srcItemis an single field valuepublic function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj)but here object
– Amit Bera♦
May 29 at 10:31
add a comment |
I have a little problem. I am currently working on an synchronize job for cron.
The sync function just gets the newest elements from an api and updates in the Magento db. The Magento version is: 2.3.1 .
Here is the function:
public function synchronize()
$writer = new Stream(BP . '/var/log/cron.log');
$logger = new Logger();
$logger->addWriter($writer);
$login = $this->login();
$dateTimestamp = $this->getLatestDate('/tmp/marketsSync.txt');
$items = $this->getNewestItems($dateTimestamp, $login);
foreach ($items as $item)
$srcItem = $this->_marketFactory->create();
$srcItem->setContent($item);
$marketCollection = $this->_marketCollectionFactory->create();
$marketCollection
->addFieldToSelect('*')
->addFieldToFilter('id_location', ['eq' => $srcItem->getData('id_location')])
->load();
$logger->info('found? :'. $marketCollection->getSize());
if ($marketCollection->getSize())
$tgtItem = $marketCollection->getFirstItem();
$srcTime = strtotime($srcItem->getData('date_upd'));
$tgtTime = strtotime($tgtItem->getData('date_upd'));
if ($srcTime > $tgtTime)
$this->updateElement($tgtItem, $srcItem);
else
$logger->info('create');
$this->createElement($srcItem, $marketCollection);
$this->setLatestDate('/tmp/marketsSync.txt', date("Y-m-d H:i:s") );
public function createElement(Synchronizable $obj)
$item = $this->_marketFactory->create();
$item->setContent($obj->getData());
$item = $item->save();
public function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj)
$writer = new Stream(BP . '/var/log/cron.log');
$logger = new Logger();
$logger->addWriter($writer);
$tgtObj->setContent($srcObj->getData());
$logger->info($tgtObj->getData());
$tgtObj->save();
I've got the Object to update from the marketCollection via getFirstItem(). Now in the updateElement() function i use the the api data to update the object with
$tgtObj->setContent($srcObj->getData());
This function is just a foreach loop:
public function setContent($content)
foreach ($content AS $key => $value)
$this->setData($key, $value);
I know that this method is already deprecated, but why does save allways create a new entry? (it creates the same data but with a new id)
magento2.3 cron
I have a little problem. I am currently working on an synchronize job for cron.
The sync function just gets the newest elements from an api and updates in the Magento db. The Magento version is: 2.3.1 .
Here is the function:
public function synchronize()
$writer = new Stream(BP . '/var/log/cron.log');
$logger = new Logger();
$logger->addWriter($writer);
$login = $this->login();
$dateTimestamp = $this->getLatestDate('/tmp/marketsSync.txt');
$items = $this->getNewestItems($dateTimestamp, $login);
foreach ($items as $item)
$srcItem = $this->_marketFactory->create();
$srcItem->setContent($item);
$marketCollection = $this->_marketCollectionFactory->create();
$marketCollection
->addFieldToSelect('*')
->addFieldToFilter('id_location', ['eq' => $srcItem->getData('id_location')])
->load();
$logger->info('found? :'. $marketCollection->getSize());
if ($marketCollection->getSize())
$tgtItem = $marketCollection->getFirstItem();
$srcTime = strtotime($srcItem->getData('date_upd'));
$tgtTime = strtotime($tgtItem->getData('date_upd'));
if ($srcTime > $tgtTime)
$this->updateElement($tgtItem, $srcItem);
else
$logger->info('create');
$this->createElement($srcItem, $marketCollection);
$this->setLatestDate('/tmp/marketsSync.txt', date("Y-m-d H:i:s") );
public function createElement(Synchronizable $obj)
$item = $this->_marketFactory->create();
$item->setContent($obj->getData());
$item = $item->save();
public function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj)
$writer = new Stream(BP . '/var/log/cron.log');
$logger = new Logger();
$logger->addWriter($writer);
$tgtObj->setContent($srcObj->getData());
$logger->info($tgtObj->getData());
$tgtObj->save();
I've got the Object to update from the marketCollection via getFirstItem(). Now in the updateElement() function i use the the api data to update the object with
$tgtObj->setContent($srcObj->getData());
This function is just a foreach loop:
public function setContent($content)
foreach ($content AS $key => $value)
$this->setData($key, $value);
I know that this method is already deprecated, but why does save allways create a new entry? (it creates the same data but with a new id)
magento2.3 cron
magento2.3 cron
edited May 29 at 10:23
Amit Bera♦
60.8k1682181
60.8k1682181
asked May 29 at 9:00
user3541236user3541236
133
133
At ` $this->updateElement($tgtItem, $srcItem);` ,$srcItemis an single field valuepublic function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj)but here object
– Amit Bera♦
May 29 at 10:31
add a comment |
At ` $this->updateElement($tgtItem, $srcItem);` ,$srcItemis an single field valuepublic function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj)but here object
– Amit Bera♦
May 29 at 10:31
At ` $this->updateElement($tgtItem, $srcItem);` ,
$srcItem is an single field valuepublic function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj) but here object– Amit Bera♦
May 29 at 10:31
At ` $this->updateElement($tgtItem, $srcItem);` ,
$srcItem is an single field valuepublic function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj) but here object– Amit Bera♦
May 29 at 10:31
add a comment |
1 Answer
1
active
oldest
votes
I found out what the problem was. I had overridden getIdentities but the name was not right.
In the Model now:
/**
* Get ID
*
* @return int|null
*/
public function getId()
return $this->getData('location_id');
/**
* Return identities
* @return string[]
*/
public function getIdentities()
return [self::CACHE_TAG . '_' . $this->getId()];
And now it works.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276541%2fmagento-always-creates-new-entries%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I found out what the problem was. I had overridden getIdentities but the name was not right.
In the Model now:
/**
* Get ID
*
* @return int|null
*/
public function getId()
return $this->getData('location_id');
/**
* Return identities
* @return string[]
*/
public function getIdentities()
return [self::CACHE_TAG . '_' . $this->getId()];
And now it works.
add a comment |
I found out what the problem was. I had overridden getIdentities but the name was not right.
In the Model now:
/**
* Get ID
*
* @return int|null
*/
public function getId()
return $this->getData('location_id');
/**
* Return identities
* @return string[]
*/
public function getIdentities()
return [self::CACHE_TAG . '_' . $this->getId()];
And now it works.
add a comment |
I found out what the problem was. I had overridden getIdentities but the name was not right.
In the Model now:
/**
* Get ID
*
* @return int|null
*/
public function getId()
return $this->getData('location_id');
/**
* Return identities
* @return string[]
*/
public function getIdentities()
return [self::CACHE_TAG . '_' . $this->getId()];
And now it works.
I found out what the problem was. I had overridden getIdentities but the name was not right.
In the Model now:
/**
* Get ID
*
* @return int|null
*/
public function getId()
return $this->getData('location_id');
/**
* Return identities
* @return string[]
*/
public function getIdentities()
return [self::CACHE_TAG . '_' . $this->getId()];
And now it works.
answered May 29 at 13:52
user3541236user3541236
133
133
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276541%2fmagento-always-creates-new-entries%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
At ` $this->updateElement($tgtItem, $srcItem);` ,
$srcItemis an single field valuepublic function updateElement(Synchronizable $tgtObj, Synchronizable $srcObj)but here object– Amit Bera♦
May 29 at 10:31