There is… but it’s not pretty.
Depending on what the second sote built on .Net is, there may be a “gateway” or adapter that can work between that and WordPress, but the chances of that are pretty slim. Still worth a look though.
If there’s nothing out there. you’ll have to write your own bridge between the two systems. It’s won’t be easy, but it is possible. You’ll need to know all about the database schemas on both sides, and how they will corresond to the other side, and then set up triggers in both systems that will be activated when changes are made that push the changes through to the other system.
Thanks for the info @catacaustic
I am able to update a CSV file, no problem, that will list stock levels.
Then I need to set up a WordPress Cron job to read the CSV file every hour and update the database…unfortunately I’ve never written a cron job before. Can i define it in functions.php? If you have any advice on writing a cronjob for reading a CSV file and updating the database with it, i’d love to hear it as I haven’t worked with WordPress before!
this is as far as I have gotten:
// Scheduled Action Hook
function updatedb( ) {
}
// Schedule Cron Job Event
function update_stock_cron_job() {
if ( ! wp_next_scheduled( ‘updatedb’ ) ) {
wp_schedule_event( time(), ‘hourly’, ‘updatedb’ );
}
}
add_action( ‘wp’, ‘update_stock_cron_job’ );
-
This reply was modified 8 years, 9 months ago by
buffyfan.
I tried this but it doesn’t work and stopped people being able to add anything to their basket.
<?php
// Scheduled Action Hook
function updatedb( ) {
$myfile = fopen("somefilename.csv", "r") or die("Unable to open file!");
$csvArray = array_map('str_getcsv', file($myfile));
global $wpdb;
foreach($csvArray as $csvEntry) {
$value = $csvEntry[2];
$field = $csvEntry[1];
$sku = $csvEntry[0];
$wpdb->update(
ppwp_postmeta,
array( meta_value = $value,
),
array( meta_key = $field AND
post_id = (select post_id
from (select
meta_value,
post_id
from ppwp_postmeta
where meta_key = '_sku') as sku_post
where meta_value = $sku);
)
);
}
fclose($myfile);
}
// Schedule Cron Job Event
function update_stock_cron_job() {
if ( ! wp_next_scheduled( ‘updatedb’ ) ) {
wp_schedule_event( time(), ‘hourly’, ‘updatedb’ );
}
}
add_action( ‘wp’, ‘update_stock_cron_job’ );
?>
Any help GREATLY appreciated.
-
This reply was modified 8 years, 8 months ago by
buffyfan.
So what errors are you seeing? What’s happening through the code? What de-bugging have you done?
As bad as it is, “not working” doesn’t give anyone much to go on, as it could be one of 1,000’s of things from code problems to server configuration.