I'm trying to update the prices of each country for a certain sku:
[['sku', 'country', 'currency', 'price']]
['apples_30', 'KE', 'KES', 300.0]
['apples_30', 'LK', 'LKR', 475.0]
['apples_30', 'US', 'USD', 2.99]
['apples_30', 'LV', 'EUR', 3.39]
['apples_30', 'CA', 'CAD', 3.99]
['apples_30', 'TZ', 'TZS', 6500.0]
['apples_30', 'KH', 'USD', 2.99]
['apples_30', 'MX', 'MXN', 55.0]
['apples_30', 'HR', 'HRK', 26.0]...
I am using the inappproducts().update() method with these parameters:
request = pubapi.inappproducts().update(packageName=package_name, sku = 'apples_30', body = testbody)
result = request.execute()
using this testbody:
{'packageName': 'com.package.name',
'prices': {'CA': {'currency': 'CAD', 'priceMicros': '3600000'},
'HR': {'currency': 'HRK', 'priceMicros': '11390000'},
'KE': {'currency': 'KES', 'priceMicros': '300000000'},
'KH': {'currency': 'USD', 'priceMicros': '2990000'},
'LK': {'currency': 'LKR', 'priceMicros': '314730000'},
'LV': {'currency': 'EUR', 'priceMicros': '1460000'},
'MX': {'currency': 'MXN', 'priceMicros': '26580000'},
'TZ': {'currency': 'TZS', 'priceMicros': '6500000000'},
'US': {'currency': 'USD', 'priceMicros': '2990000'}},
'sku': 'apples_30'}
My problem is I'm getting this error.
{'code': 400, 'errors': [{'message': 'Invalid price {0}.', 'domain':
'androidpublisher', 'reason': 'inAppProductInvalidPrice'}], 'message':
'Invalid price {0}.'}
I understand this is self-explanatory, but I don't get why this is an invalid price when I'm using the same format as what I got from the inappproducts().list() method:
{'sku': 'apples_30',
'prices': {'KE': {'priceMicros': '200000000', 'currency': 'KES'},
'LK': {'priceMicros': '150000000', 'currency': 'LKR'},
'US': {'priceMicros': '990000', 'currency': 'USD'},
'LV': {'priceMicros': '1090000', 'currency': 'EUR'},
'CA': {'priceMicros': '1290000', 'currency': 'CAD'},...
If anyone can point me to the right direction, that'd be great! Really need help. Documentation is seriously lacking. :/
Thanks!
nvm. figured it out. you have to use the whole resource representation as the request body. here it is: https://developers.google.com/android-publisher/api-ref/inappproducts#resource
Related
This code is working fine to uopload image in Zoho Inventory
*You can Used this code to upload image in zoho inventory.
Item id*
authtoken*
organization_id*
PHP Curl code
'https://inventory.zoho.com/api/v1/items//image?authtoken=xxxxxxx&organization_id=xxxxxxx',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('image'=> new CURLFILE('/C:/Users/shobh/OneDrive/Pictures/WE\'RE HIRING (1).png')),
CURLOPT_HTTPHEADER => array(
'Authorization: Zoho-oauthtoken xxxxxxxxx',
'Cookie: xxxxxxx'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
*Response*
[enter image description here][1]
[1]: https://i.stack.imgur.com/jsKoV.png
I have a particular issue with inserting custom posts with wp_insert_posts.
Circumstances:
WPML
Multisite enabled
Custom post type with name order
Post creation triggered through Ajax from frontend
The post is inserted in the original language, no translations
What have I tried so far
Checked the post type register code to see if it contains any incompatible settings, tried all combinations -> noting. This is what is the closest thing to my problem: wp_insert_post entries not showing in admin content list
The resolution there is not applicable to me, as I execute it through Ajax, and WP is already initialized at the Ajax hook
Went through WPML forums with all their posts related to similar issues, tried the steps provided there (although most of them talk about adding translations)
Tried various other solutions
Post insert code:
$post_id = wp_insert_post([
"post_type" => "order",
"post_content" => "",
"post_title" => $order->Name() . '<' . $order->Email() . '>',
"post_status" => "publish",
"post_author" => 1
]);
update_post_meta($post_id, 'order_details', '{"some":"json here"}');
The post gets inserted in the table, and the listing page in admin shows it in the total counts, but the post doesn't show up in the list itself.
Post type register code
if ( ! function_exists('ls_so_order') ) {
// Register Custom Post Type
function ls_so_order() {
$labels = array(
'name' => _x( 'Orders', 'Post Type General Name', 'ls-simple-order' ),
'singular_name' => _x( 'Order', 'Post Type Singular Name', 'ls-simple-order' ),
'menu_name' => __( 'Orders', 'ls-simple-order' ),
'name_admin_bar' => __( 'ProductOrder', 'ls-simple-order' ),
'archives' => __( 'Order Archives', 'ls-simple-order' ),
'attributes' => __( 'Order Attributes', 'ls-simple-order' ),
'parent_item_colon' => __( 'Parent Order:', 'ls-simple-order' ),
'all_items' => __( 'All Orders', 'ls-simple-order' ),
'add_new_item' => __( 'Add New Order', 'ls-simple-order' ),
'add_new' => __( 'Add New', 'ls-simple-order' ),
'new_item' => __( 'New Order', 'ls-simple-order' ),
'edit_item' => __( 'Edit Order', 'ls-simple-order' ),
'update_item' => __( 'Update Order', 'ls-simple-order' ),
'view_item' => __( 'View Order', 'ls-simple-order' ),
'view_items' => __( 'View Orders', 'ls-simple-order' ),
'search_items' => __( 'Search Order', 'ls-simple-order' ),
'not_found' => __( 'Not found', 'ls-simple-order' ),
'not_found_in_trash' => __( 'Not found in Trash', 'ls-simple-order' ),
'featured_image' => __( 'Featured Image', 'ls-simple-order' ),
'set_featured_image' => __( 'Set featured image', 'ls-simple-order' ),
'remove_featured_image' => __( 'Remove featured image', 'ls-simple-order' ),
'use_featured_image' => __( 'Use as featured image', 'ls-simple-order' ),
'insert_into_item' => __( 'Insert into order', 'ls-simple-order' ),
'uploaded_to_this_item' => __( 'Uploaded to this order', 'ls-simple-order' ),
'items_list' => __( 'Orders list', 'ls-simple-order' ),
'items_list_navigation' => __( 'Orders list navigation', 'ls-simple-order' ),
'filter_items_list' => __( 'Filter orders list', 'ls-simple-order' ),
);
$args = array(
'label' => __( 'Order', 'ls-simple-order' ),
'description' => __( 'Simple Order Orders', 'ls-simple-order' ),
'labels' => $labels,
'supports' => array( 'title', 'thumbnail', 'custom-fields' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-cart',
'show_in_admin_bar' => true,
'show_in_nav_menus' => false,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => true,
'publicly_queryable' => false,
'capability_type' => 'page',
);
register_post_type( 'order', $args );
}
add_action( 'init', 'ls_so_order', 0 );
}
Can you try doing this?
$post_data = array(
'post_title' => 'Test regex',
'post_content' => $order->Name() . '<' . $order->Email() . '>',
'post_type' => 'post',
'post_status' => 'publish',
'post_author' => 1,
);
$post_id = wp_insert_post($post_data);
update_post_meta($post_id, 'order_details', '{"some":"json here"}');
After going back and forth in every forum I could find, and tinkering with #miguelcalderons answer, I found the culprit, and it is a very simple, although quiet hidden thing.
WordPress Reserved Terms
WordPress has a quiet long list of reserved terms, and order being one of them.
After replacing the custom post type slug with a different string, it started working immediately.
I am trying to create a configurable product and its associated product using magento soap api.Product created successfully but configurable product linking with associated product is not working properly guys any idea? This is my code
<?php
$client = new SoapClient('https://sample.com/api/v2_soap?wsdl=1');
// If some stuff requires api authentification,
// then get a session token
$session = $client->login('username', 'Password');
// get attribute set
$attributeSets = $client->catalogProductAttributeSetList($session);
$attributeSet = current($attributeSets);
print_r($attributeSet);
$result = $client->catalogProductCreate($session, 'simple',72, 'product_sku0002', array(
'categories' => array(2),
'websites' => array(1),
'name' => 'Product name',
'description' => 'Product description',
'short_description' => 'Product short description',
'weight' => '10',
'status' => '1',
'url_key' => 'product-url-key',
'url_path' => 'product-url-path',
'visibility' => '4',
'price' => '100',
'tax_class_id' => 1,
'meta_title' => 'Product meta title',
'meta_keyword' => 'Product meta keyword',
'meta_description' => 'Product meta description',
'additional_attributes' => array(
'single_data' => array(
array(
'key' => 'color',
'value' => 'Red', // Id or label of color, attribute that will be used to configure product
)
),
),
));
var_dump ($result);
$result = $client->catalogProductCreate($session, 'configurable',72, 'Configurable_product_sku0001', array(
'categories' => array(2),
'websites' => array(1),
'name' => 'Confihurable Product name',
'description' => 'Product description',
'short_description' => 'Product short description',
'weight' => '10',
'status' => '1',
'url_key' => 'product-url-key',
'url_path' => 'product-url-path',
'visibility' => '4',
'price' => '100',
'tax_class_id' => 1,
'meta_title' => 'Product meta title',
'meta_keyword' => 'Product meta keyword',
'meta_description' => 'Product meta description',
'associated_skus' => array('product_sku0002'),
'price_changes' => array(
array(
'color' => array(
'Red' => '0'
)
),
),
));
var_dump ($result);
?>
Its working fine using this method follow the link
http://www.bubblecode.net/en/2012/04/20/magento-api-associate-simple-products-to-configurable-or-grouped-product/
I have added some custom variables to customer and I want to use them in email template.
Here's example how I have added a variable to customer in my installer:
$setup->addAttribute('customer', 'companyname', array(
'input' => 'text',
'type' => 'varchar',
'label' => 'Company name',
'visible' => 1,
'required' => 1,
'user_defined' => 1,
));
$setup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$attributeGroupId,
'companyname',
'999' //sort_order
);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'companyname');
$oAttribute->setData('used_in_forms', array('adminhtml_customer','customer_account_create'));
$oAttribute->save();
I try to use this variable in email template:
{{var order.getCustomer().getCompanyname()}}
But it's not showing. How to make it work?
I done similar task with code like below:
$setup->addAttribute('customer', 'attr_name', array(
'type' => 'int',
'input' => 'select',
'label' => 'Attr label',
'global' => 1,
'visible' => 1,
'required' => 1,
'default' => '0',
'user_defined' => 1,
'visible_on_front' => 1,
));
if (version_compare(Mage::getVersion(), '1.6.0', '<='))
{
$customer = Mage::getModel('customer/customer');
$attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
$setup->addAttributeToSet('customer', $attrSetId, 'General', 'attr_name');
}
if (version_compare(Mage::getVersion(), '1.4.2', '>='))
{
Mage::getSingleton('eav/config')
->getAttribute('customer', 'attr_name')
->setData('used_in_forms', array('customer_account_create'))
->save();
}
Next have tested it (right now) within "Order new" email {{var order.getCustomer().getAttrName()}} and have got correct value.
Try it, might it helps to you.
I need a dropdown attribute in category. I tried to do this in installer:
$installer = $this;
$installer->startSetup();
$entityTypeId = $installer->getEntityTypeId('catalog_category');
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$installer->addAttribute('catalog_category', 'priority', array(
'type' => 'varchar',
'label' => 'Priority2',
'input' => 'select',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => false,
'option' => array(
'value' => array(
0 => array(''),
1 => array('normal'),
2 => array('grouping'),
3 => array('highlighted'),
4 => array('trendy'),
),
),
'default' => array(0),
));
$installer->addAttributeToGroup(
$entityTypeId, $attributeSetId, $attributeGroupId, 'priority', '11'
);
$attributeId = $installer->getAttributeId($entityTypeId, 'priority');
$installer->run("
INSERT INTO `{$installer->getTable('catalog_category_entity_int')}`
(`entity_type_id`, `attribute_id`, `entity_id`, `value`)
SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
FROM `{$installer->getTable('catalog_category_entity')}`;
");
Mage::getModel('catalog/category')
->load(1)
->setImportedCatId(0)
->setInitialSetupFlag(true)
->save();
Mage::getModel('catalog/category')
->load(2)
->setImportedCatId(0)
->setInitialSetupFlag(true)
->save();
$installer->endSetup();
but it doesn't work. Nothing shows up in Catalog->categories->Manage Categories. I can create only textfield attribute like this:
$installer->addAttribute('catalog_category', 'priority', array(
'type' => 'varchar',
'label' => 'Priority2',
'input' => 'text',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '',
));
Do you have any ideas?
Thx for help.
EDIT.
I also tied SQL query like this:
INSERT INTO eav_attribute (entity_type_id, attribute_code, attribute_model, backend_model, backend_type, backend_table, frontend_model, frontend_input, frontend_label, frontend_class, source_model, is_required, is_user_defined, default_value, is_unique, note) VALUES
(9, 'priority', NULL, 'NULL', 'int', 'NULL', 'NULL', 'select', 'Priority', NULL, 'eav/entity_attribute_source_table', 1, 0, 0, 0, '');
INSERT INTO eav_attribute_option (option_id,attribute_id,sort_order) VALUES
(1500,282,0),
(1501,282,1),
(1502,282,2),
(1503,282,3),
(1504,282,4);
INSERT INTO eav_attribute_option_value (value_id,option_id,store_id,value) VALUES
(201,1500,0,''),
(202,1501,0,'normal'),
(203,1502,0,'grouping'),
(204,1503,0,'highlighted'),
(205,1504,0,'trendy');
INSERT INTO eav_entity_attribute (entity_type_id, attribute_set_id, attribute_group_id, attribute_id, sort_order) VALUES
(9, 12, 7, (SELECT atribute_id FROM eav_attribute WHERE attribute_code='priority'), 2);
It's possible using module installer:
$installer->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'myattribute', array(
'type' => 'varchar',
'label' => 'My attribute',
'source' => 'module/category_attribute_myattribute',
'backend' => 'module/category_attribute_backend_myattribute',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'input' => 'select',
'visible' => true,
'required' => true,
'user_defined' => false,
'used_in_product_listing' => false,
'group' => 'Group name',
'default' => Module_Catalog_Model_Category_Attribute_Myattribute::DEFAULT_Groupname,
));
Hope it helps someone ;)
Please refer the tutorial for file structure and step by step explanation.
http://www.pearlbells.co.uk/how-to-add-custom-dropdown-attribute-to-magento-category-section/
<?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'custom_dropdown', array(
'group' => 'General Information',
'input' => 'select',
'type' => 'text',
'label' => 'Custom Dropdown',
'backend' => '',
'visible' => true,
'required' => false,
'visible_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'source' => 'customfeaturedattribute/source_custom',
));
$this->endSetup();
And in the model class add the options.
public function getAllOptions()
{
$options = array(
1 => 'One',
2 => 'Two',
3 => 'Three'
);
return $options;
}