Connect to online Magento from a localhost - php

Beside setting up a custom Magento API, is there a way to connect from a localhost webapp to an online Magento installation? More specifically, I'm looking for a setup that will allow me to write codes like
include('app/Mage.php'); // how does this work for online-offline connection??
$products = Mage::getModel('catalog/category')->load($category_id);
in a webapp running on localhost in our office.
If this is not plausible, do I need to connect to the Magento store DB directly from my application and basically write my own queries? I would certainly create a new user with read-only access for the DB, if this was the case.

No need to connect to the db the include will handle it:
require'app/Mage.php';
if (!Mage::isInstalled()) {
Mage::log("Application is not installed yet, please complete install wizard first.\n",null,'fiftyone_daemon.log');
exit;
}
Mage::app('default');
$products = Mage::getModel('catalog/category')->load($category_id);

Related

Testlink integration with redmine (interface:rest) is not working

We have Redmine & Testlink hosted on 2 different servers on Amazon Cloud.
I used below methods / workarounds to establish a connection between these two, however I am getting "Something is preventing to connect to bug tracking system, it will create performance issue..." on Execute Test page of testlink.
Made below configuration in Issue Tracker Management under
Redmine(interface:rest)
<issuetracker>
<apikey>3fe68920f3cf</apikey>
<uribase>https://odessa.sharred.net</uribase>
<uriview>https://odessa.sharred.net/redmine/CM/issues/</uriview> <!-- for Redmine 1.x add show/ -->
<projectidentifier>Common</projectidentifier>
</issuetracker>
Enabled API from redmine.
Made settings in C:\xampp\htdocs\testlink\third_party\redmine-php-api\lib\redmine-rest-api.php for curl_setopt() to allow to use HTTPS.
Tried giving Redmine Base URL using IP ADDRESS instead of Host name.
Do not see any relevant logs in testlink's events section.
Added entry of redmine in config.inc.php with $g_interface_bugs='REDMINE';
Also observed that URL given in URIBASE is opening in web browser with parameter passed as key i.e. https://odessa.sharred.net?key=3fe68920f3cf
is accessible from testlink server.
Any insight / solution on this issue will be great help.
Your configuration should look something like this.
<issuetracker>
<apikey>3fe68920f3cf</apikey>
<uribase>https://ServerIP/redmine</uribase>
<uriview>https://ServerIP/redmine/issues/</uriview>
<projectidentifier>CM</projectidentifier>
</issuetracker>
I also had trouble and just got it working now.
If you still have issue goto http://TLServerIP/testlink/lib/events/eventviewer.php and check the error
Similarly you can go to //redmineinstalldir/apps/redmine/htdocs/log/production.log to see what error you are getting after you click test connection on testlink

PHP code working locally but not on Azure

I've implemented a mail delivery service using SparkPost for a website. The code looks like this:
require '/vendor/autoload.php';
use SparkPost\SparkPost; use GuzzleHttp\Client;
use Ivory\HttpAdapter\Guzzle6HttpAdapter;
$httpAdapter = new Guzzle6HttpAdapter(new Client());
$sparky = new SparkPost($httpAdapter, ['key'=>'...']);
[...]
[...]
$results = $sparky->transmission->send($mailarray);
It works just fine locally on WampServer, however when I deploy it to Azure it does not. I don't have access to Azure logs, but I managed to narrow down the problem to one line:
$sparky = new SparkPost($httpAdapter, ['key'=>'...']);
I simply get a 500 error without any other explanation. The weird thing is when I wrap it around a try/catch, I still don't get anything other than a blank screen and a 500 on the console. I suspect it has to do something with /autoload.php not being able to load something.
Any thoughts?
According the requirement of SparkPost lib on Github repo at https://github.com/SparkPost/php-sparkpost/blob/master/composer.json#L18, it need PHP version higher than 5.5. So you can modify the PHP version of your Azure Web Apps, please refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-php-configure/#how-to-change-the-built-in-php-version for detail steps.

mysqldump-php not working with shared hosting companies database. No command line access or SUPER privilege(s)

Does anyone know if mysqldump-php can work with shared hosting? I can get it to work on my local computer (I can get mysqldump to work locally also) but I need a method to backup a database that's hosted with a popular webhosting company. The only method that they offer to their customers is to sign onto phpMyAdmin and download your .sql manually. daily. yourself. no automation allowed. I'm a newbie and I'm going nuts trying to find a solution.
mysqldump-php called for
namespace Ifsnop\Mysqldump;
use Exception;
use PDO;
use PDOException;
It didn't mention needing command line access or SUPER privilege(s).
Am I using incorrect settings?
Here's the link to the code that I'm using on Github.
https://github.com/ifsnop/mysqldump-php#dump-settings
Any help would be so appreciated!
I've had a look in the code of ifsnop, and it uses SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ before starting the transaction. Global settings are only allowed with the SUPER-privilege (which you don't have on a shared environment, with a good reason ;) ).
You can either:
If you have only MyISAM-tables, there is no need for a transaction, so it can be turned off in the config.
$dumpConfig = array(
'single-transaction' => false
);
$md = new Mysqldump($db, $user, $pass, $host, 'mysql', $dumpConfig);
or; Change that word GLOBAL into SESSION (thus modifying the downloaded code).

Unable to query RoleEnvironment with Windows Azure SDK for PHP

I have an issue with obtaining data from Windows Azure's runtime using the newest (at the time of writing) PHP SDK from Github. Here is a test I am running on one of our hosted services:
<?php
include 'WindowsAzure/WindowsAzure.php';
use \WindowsAzure\ServiceRuntime\RoleEnvironment;
use \WindowsAzure\ServiceRuntime\Internal\RoleEnvironmentNotAvailableException;
try {
echo RoleEnvironment::getDeploymentId();
}
catch (RoleEnvironmentNotAvailableException $Exception) {
die('Failed to find deployment id');
}
RoleEnvironmentNotAvailableException is always thrown. Looking at the source, it seems to try sending commands through a named pipe (\.\pipe\WindowsAzureRuntime). Do I need to specify something within my ServiceConfiguration.csdef/cscfg in order to have access to this named pipe?
Any advice would be most welcome!
Got confirmation from MS EMEA Developer Support that current SDK does not support this function. They suggested similar workaround to jonnu above - use the previous SDK's functionality for role environment / configuration settings.
The ServiceRuntime APIs run only on Cloud so if this code snippet runs on local machine it'll throw an exception as you've pointed out. Further, if you want to debug your ServiceRuntime code you've to deploy your service to WA then use remote desktop connection to access the cloud machine and debug your code.

issue creating new db in wordpress mysql

I'm working on a WordPress theme that requires a db in mysql to store lots of data.
I'm currently working on an installation script to install the theme. I have written a function to create a new db in the same mysql that WordPress uses it self.
Every time i run the script, i get redirected to a page stating that WordPress is already installed. But I'm not trying to reinstall WordPress, just create a new db in the same sql that WordPress uses.
I have also written a function to create new tables, which works fine so I'm sure there is no issues with connection.
If this helps, here is the function:
function create_db_mysql(){
require ('con_db_var/db_4216841335655434.php');
$connect = mysql_connect($db_host,$db_user,$db_pswrd) or die(mysql_error());
mysql_query("CREATE DATABASE theme_db",$connect);
mysql_close($connect);
}
I fetch the db info from wp-config.php.
so in the db_4216841335655434.php:
require ('../../../wp-config.php');
$db_host = ( DB_HOST );
//etc etc....
when i call the create_db_mysql(), I get taken to a page telling me that WordPress is already installed and then followed by instructions on how to re-install.
any ideas?
thanks!
Database creation and table creation are different levels of privileges. Many shared hosting providers will not give PHP the access to create a database.
So you might need to use your hosting providers control panels to create the database.

Categories