Error during assigning product image through soap api Magento - magento

HI i have just start learning soap api in magento . In this i have create a product through soap and now i want to assign product images through it.
for that i am using below code
<?php $client = new SoapClient('http://localhost/magento1.9/index.php/api/v2_soap/?wsdl');
$session = $client->login('111111', '111111');
$newImage = array(
'file' => array(
'name' => 'file_name',
'content' => base64_encode(file_get_contents('heart_circle.png')),
'mime' => 'image/jpeg'
),
'label' => 'Cool Image Through Soap',
'position' => 2,
'types' => array('small_image'),
'exclude' => 0
);
$imageFilename = $client->call($session, 'product_media.create', array('product_sku', $newImage));
var_dump($imageFilename);
?>
but i am getting below error Fatal error: Uncaught SoapFault
exception: [Client] Function ("call") is not a valid method for this
service in /var/www/soap.php:19 Stack trace: #0 /var/www/soap.php(19):
SoapClient->__call('call', Array) #1 /var/www/soap.php(19):
SoapClient->call('92b56ed9ed1c9b5...', 'product_media.c...', Array) #2
{main} thrown in /var/www/soap.php on line 19
Please suggest me where i am doing mistake. thanks

Hi i have found the issue it was the wrong soap version mention in the url
http://localhost/magento1.9/index.php/api/v2_soap/?wsdl //previous
http://localhost/magento1.9/index.php/api/soap/?wsdl // new
thanks

Related

Use of undefined constant INTL_IDNA_VARIANT_UTS46 error while doing payment on stripe, Laravel

I am getting this error while doing payment on stripe Laravel.
Use of undefined constant INTL_IDNA_VARIANT_UTS46 - assumed
'INTL_IDNA_VARIANT_UTS46'
My controller:
$stripe_secret = config('services.stripe.secret');
$stripe = Stripe::make($stripe_secret);
$charge = $stripe->charges()->create([
'currency' => 'USD',
'amount' => (float)$amount,
'source' => $payment_token,
'description' => '',
'receipt_email' => $receipt_email,
]);
This blog post describes the issue you're having. To fix the issue you should avoid guzzle 6.5.0.

Indipay parameter missing exception

I am sending all the parameters required by indipay but still i am getting a parameter missing exception. If i send the static values then it is working fine.
$parameters = [
'purpose' => 'Application Fee for '.$regnId,
'buyer_name' => $request->s_fname.' '.$request->s_lname,
'amount' => env('APPLICATION_FEE'),
];
$order = Indipay::prepare($parameters);
return Indipay::process($order);
IndipayParametersMissingException in InstaMojoGateway.php line 119 at
InstaMojoGateway->checkParameters(array('redirect_url' =>
'http://127.0.0.1:8000/parent/response/indipay', 'purpose' =>
'Application Fee for GKB_19LKG_000019', 'buyer_name' => 'asdasd
asdasd', 'amount' => '200')) in InstaMojoGateway.php line 41
I finally found the answer.
The indipay package didn't gave the correct error. There was no parameter missing in the request. There was a max size issue in the validator function for the instamojo payment gateway.

While create adset then I got error 'Invalid parameter'

I am using FB Ads API, and successfully created campaigns and get the ID from Facebook. In the next step to create adset with below code then got error.
// Call create using an array of parameters.
$data = array(
AdSetFields::NAME => 'My AdSet',
AdSetFields::BID_TYPE => 'CPC',
AdSetFields::BID_INFO => array(
'CLICKS' => 500,
),
AdSetFields::CAMPAIGN_STATUS => AdSet::STATUS_ACTIVE,
AdSetFields::DAILY_BUDGET => 200,
AdSetFields::CAMPAIGN_GROUP_ID => $campaign_id,
AdSetFields::TARGETING => array(
'geo_locations' => array(
'countries' => array(
'US',
'GB',
),
),
),
);
$ad_set = new AdSet(null, $account->id);
$ad_set->create($data);
Fatal error: Uncaught exception 'FacebookAds\Http\Exception\AuthorizationException' with message 'Invalid parameter' in /www/facebookads/src/FacebookAds/Http/Exception/RequestException.php:129
I got solution for this error,
DAILY_BUDGET - increased upto 4000 then it is converted to INR 40.00
then I created adset successfully

Unable to create image in magento api if product SKU contains slash(/)

I'm trying to create an image via magento image api by following the same code in this magento doc.
And its working fine except the SKU contains slash(/) character.
SKU: SPA-1XCHOC12/DS0
Here is the Error shows in httpd/error_log:
[Fri Feb 21 07:35:33 2014] [error] [client 8.35.201.40] PHP Fatal error: Uncaught SoapFault exception: [104] Cannot create image. in /var/www/html/product_api/image.php:22\nStack trace:\n#0 /var/www/html/product_api/image.php(22): SoapClient->__call('call', Array)\n#1 /var/www/html/product_api/image.php(22): SoapClient->call('67da4ad39466d6e...', 'product_media.c...', Array)\n#2 {main}\n thrown in /var/www/html/product_api/image.php on line 22
To identify the exact issue, i have added this code
$this->_fault('not_created', $e->getMessage()); in app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api.php
And this is the error:
[Fri Feb 21 07:41:56 2014] [error] [client 8.35.201.42] PHP Fatal error: Uncaught SoapFault exception: [104] Folder 'SPA-1XCHOC12' isn't writeable in /var/www/html/product_api/image.php:22\nStack trace:\n#0 /var/www/html/product_api/image.php(22): SoapClient->__call('call', Array)\n#1 /var/www/html/product_api/image.php(22): SoapClient->call('7f82eac2c509869...', 'product_media.c...', Array)\n#2 {main}\n thrown in /var/www/html/product_api/image.php on line 22
And media/catalog/product folder permission is 777. Still showing the same error.
Here is my Code:
Post Values are sku = 'SPA-1XCHOC12/DS0' and image_url='http://example.com/11233.jpg'
$sessionId = $proxy->login($api_user, $api_pwd);
$newImage = array(
'file' => array(
'name' => $_POST['sku'],
'content' => base64_encode(file_get_contents($_POST['img_url'])),
'mime' => 'image/jpeg'
),
'position' => 0,
'types' => array('small_image', 'image', 'thumbnail'),
'exclude' => 0
);
$imageFilename = $proxy->call($sessionId, 'product_media.create', array($_POST['sku'], $newImage));
Since your image is being generated by the sku, which you are sending to the routine manually, then why not clean it up there. It won't affect anything else.
Post Values are sku = 'SPA-1XCHOC12/DS0' and image_url='http://example.com/11233.jpg'
$sessionId = $proxy->login($api_user, $api_pwd);
// Replace slashes like waldek_c suggested
$sku_filename = str_replace("/","_",$_POST['sku']).".jpg";
$newImage = array(
'file' => array(
'name' => $sku_filename, // Put filtered $sku_filename var here from above
'content' => base64_encode(file_get_contents($_POST['img_url'])),
'mime' => 'image/jpeg'
),
'position' => 0,
'types' => array('small_image', 'image', 'thumbnail'),
'exclude' => 0
);
$imageFilename = $proxy->call($sessionId, 'product_media.create', array($_POST['sku'], $newImage));
The image filename will be SPA-1XCHOC12_DS0.jpg instead of SPA-1XCHOC12/DS0.

ZF2: How do I implement a custom filter?

I've been working with Zend Framework 2 for a few weeks now, and, even though the documentation online is pretty incomplete, I managed to build up a first draft of my website.
Unfortunately, I got stuck while trying to implement a custom version of the Zend\Filter\File\Rename filter; here I sum up what I've done:
1) In my module called 'Library', created the file
src\Library\Filter\File\Rename.php
namespace Library\Filter\File;
use Traversable;
use Zend\Filter;
use Zend\Filter\Exception;
use Zend\Stdlib\ArrayUtils;
class Rename extends Filter\AbstractFilter {
static $uploadDir = '/srv/default/htdocs/public/uploads/';
public function filter($value) {
do {
$newname = md5(uniqid(time()));
} while(file_exists(self::uploadDir . $newname);
if (rename($value, self::uploadDir . $newname) !== true)
throw new Exception\RuntimeException(sprintf("File '%s' could not be renamed. An error occurred while processing the file.", $value));
return self::uploadDir . $newname;
}
}
As you can see, is pretty simple. Here's the module config:
module.config.php
<?php
return array(
'controllers' => array(
// Invokables don't support dependencies
'invokables' => array(
'myFileRename' => 'Library\Filter\File\Rename',
),
));
While the form is:
[...]
public function getInputFilterSpecification() {
return array(
'file' => array(
'required' => false,
'filters' => array(
// Custom Renamer
array('name' => 'myFileRename'),
),
)
);
}
}
?>
But this is not working, as I always get an exception:
Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for myFileRename' in /srv/default/vendor/ZF2/library/Zend/ServiceManager/ServiceManager.php:420
Stack trace:
#0 /srv/default/vendor/ZF2/library/Zend/ServiceManager/AbstractPluginManager.php(108): Zend\ServiceManager\ServiceManager->get('myfilerename', true)
#1 /srv/default/vendor/ZF2/library/Zend/Filter/FilterChain.php(179): Zend\ServiceManager\AbstractPluginManager->get('myfilerename', NULL)
#2 /srv/default/vendor/ZF2/library/Zend/InputFilter/Factory.php(263): Zend\Filter\FilterChain->attachByName('myfilerename', Array)
#3 /srv/default/vendor/ZF2/library/Zend/InputFilter/Factory.php(171): Zend\InputFilter\Factory->populateFilters(Object(Zend\Filter\FilterChain), Array)
#4 /srv/default/vendor/ZF2/library/Zend/InputFilter/Factory.php(237): Zend\InputFilter\Factory->createInput(Array)
#5 /srv/default/vendor/ZF2/library/Zend/Form/Form.php(672) in /srv/default/vendor/ZF2/library/Zend/ServiceManager/ServiceManager.php on line 420
Unfortunately I found no article on the entire internet to help me with this, and I still get this error even when aliasing my filter as a factory :/ What do I have to do?
You load the filter as if it is a controller (hence, the controller key in your module config). The filter has a plugin manager, but for this filter you do not need the plugin manager. There is also no link in the filter plugin manager with the MVC configuration.
The most simple way is to just instantiate the filter yourself. It should be something like this that would work:
use Library\Filter\File\Rename as RenameFilter;
public function getInputFilterSpecification()
{
return array(
'file' => array(
'required' => false,
'filters' => array(
new RenameFilter,
),
)
);
}
just use:
'name' => 'file',
'required' => false,
'filters' => array(
array('name' => 'Library\Filter\File\Rename'),
),
had the same problem... this was the solution for me...

Resources