Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9075397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:51:09+00:00 2026-06-16T18:51:09+00:00

I have a script that sends order data to a 3rd party system via

  • 0

I have a script that sends order data to a 3rd party system via a RESTful web service. This system demands that a unique ID is sent with each request, which is autoincremented from the next.

I’ve implemented this by adding a variable for this in Magento’s core_config_data table, and as part of my code the function below is called to get the next value for the ID, incrementing it for the next request.

class MyProject
{
    public function getNextApiId() {
        // Get the next ID.
        $id = Mage::getStoreConfig('myproject/next_api_id');

        // Increment the stored value for next time.
        $nextId = $id + 1; // change $id++ by $id + 1 otherwise the result of $nextId = $id - 1;
        Mage::getModel('core/config')->saveConfig('myproject/next_api_id',$nextId);

        // Refresh the config.
        Mage::getConfig()->cleanCache();
        Mage::getConfig()->reinit();

        // Return the ID.
        return $id;
    }
}

If I send one request with my script, this works fine – the value is incremented and the next ID is used for the next execution of the script.

However, the value appears to be cached if I’m processing multiple requests in a loop within the same script execution. The code below should illustrate the general flow, though I’ve reduced it for brevity:

function sendRequest($item) {
    $apiId = $MyProject->getNextApiId();

    // Build and send request body
}

foreach($items as $item) {
    sendRequest($item);
}

This would result in the initial ID number being used for all $items.

The cleanCache() and reinit() attempts to refresh the config cache do not seem to work at all. Any ideas on how to stop the value from being cached?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:51:10+00:00Added an answer on June 16, 2026 at 6:51 pm

    Cache must be cleaned in a different way, you have to reset the cache of the store and init it again cause of the loop. If you didn’t have a loop, it will be cleaned also but it needs a second url request of the shop which will init the cache.

    Try this instead:

    function getNextApiId() {
        // Get the next ID.
        $id = Mage::getStoreConfig('myproject/next_api_id');
    
        // Increment the stored value for next time.
        $nextId = $id + 1;
    
        Mage::getConfig()->saveConfig('myproject/next_api_id',$nextId);
    
        // Refresh the config.
        Mage::app()->getStore()->resetConfig();
    
        // Return the ID.
        return $id;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery-ajax function that sends data to a php script and the
I have a script that sends emails to a contact list. I would like
I have a PHP script that I'm invoking from another shell script that sends
So, I have a php script that sends my mp3 file to the audio
I have a simple php script on my domain that sends me an email:
to interact with my iPhone, i have created a python script that sends and
I have a script that performs a CRM system on my company and I
I have a script that sends an email using the paypal IPN after a
I have a Web server that updates its data once per minute, and want
i have this problem: I have created a bash script that performs some tasks.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.