eBay API aspectFilter with MaxPrice parameter returns 0 results - ebay-api

I am using the following URL to fetch car listing. But when I add the MaxPrice parameter It shows 0 items. But on the site there are 12 items that have price below my value.
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.12.0&SERVICE-NAME=FindingService&SECURITY-APPNAME=prosoftda-d112-4c99-9bec-8a09c902a7a&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=50&categoryId=6001&outputSelector=PictureURLSuperSize&REST-PAYLOAD=true
&aspectFilter(0).aspectName=Make&aspectFilter(0).aspectValueName=Audi
&aspectFilter(1).aspectName=Model&aspectFilter(1).aspectValueName=Q7
&aspectFilter(2).aspectName=Model+Year&aspectFilter(2).aspectValueName=2013
&aspectFilter(3).aspectName=MaxPrice&aspectFilter(3).aspectValueName=50000.00
When I remove MaxPrice parameter the URL works perfectly.

Btw, I got the solution for this question:
To pass the price value need to pass as ItemFilter. not with the AspectFilter.
I replace the string :
&aspectFilter(3).aspectName=MaxPrice&aspectFilter(3).aspectValueName=50000.00
By the string :
&itemFilter(0).name=MaxPrice&itemFilter(0).value=500000.00
So It works now. As Price parameter is related to attribute so need to pass with the ItemFilter.
So final URL Is:
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.12.0&SERVICE-NAME=FindingService&SECURITY-APPNAME=prosoftda-d112-4c99-9bec-8a09c902a7a&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=50&categoryId=6001&outputSelector=PictureURLSuperSize&REST-PAYLOAD=true
&aspectFilter(0).aspectName=Make&aspectFilter(0).aspectValueName=Audi
&aspectFilter(1).aspectName=Model&aspectFilter(1).aspectValueName=Q7
&aspectFilter(2).aspectName=Model+Year&aspectFilter(2).aspectValueName=2013
&itemFilter(0).name=MaxPrice&itemFilter(0).value=500000.00
Thanks. may be this can help someone who is finding the same question.

I have no experience with this API so this is just a shot in the dark. But I found this link:
http://developer.ebay.com/DevZone/finding/CallRef/findItemsAdvanced.html
From what Ive read within that MaxPrice is more of an "itemFilter" (things such as maxPrice, bestOfferOnly, featuredSeller) than an "aspectFilter" (things such as Make, Model, Optical Zoom).
Further down it also states that some itemFilters need a paramName, such as maxPrice
For example, if you use the MaxPrice itemFilter, you will need to specify
a parameter Name of Currency with a parameter Value that specifies the type
of currency desired.
Again never used this API but seems relevant to me.

Related

Odoo create stock.move.line to reserve stock

product_id = 465
location_id =8
product_qty =1
lot_id = 118
env['stock.move.line'].create( {
'company_id':1,
'picking_id':record.id,
'lot_id':lot_id,
'date':record.date,
'location_dest_id':5,
'location_id':location_id ,
'product_uom_qty':product_qty,
'product_uom_id':32,
'product_id':product_id
})
I am trying to create stock move line to programmtically create stock.move.line. However, after using this code, stock move line is created but it is not working normally. The Transfer can't be processed even after pressing validating without any error popping. When cancel is pressed, it say It is not possible to unreserve more products of xxxxx than you have in stock. After some researching, i am not sure if I should update stock.quant to reserve the products. Then I added these two lines of code at the bottom of the code above. However, it leads to error that said 'int' object has no attribute 'categ_id'" while evaluating........ Is my code for reservation of stock wrong or is there other way that can make this works. Thanks
if env['stock.quant']._get_available_quantity(product_id,location_id, lot_id,strict=True)>=1:
env['stock.quant']._update_available_quantity(product_id,location_id, -product_qty, lot_id,package_id=False, owner_id=False)
The _get_available_quantity function will call _gather function which will call the _get_removal_strategy function and if you provide the product_id as an integer, it will fail to get the removal_strategy_id from the product categ_id
You may notice that the _get_available_quantity function expects a recordset because of the way Odoo defines the variable rounding.

Printing watson entity found in text (input)

I have a situation, where user asks for "I want to buy us dolars". I have already defined the intent for the question "I want to buy". What I need, is to identify which currency user is talking about (buying).
For that, I created an Entity "money", with a value "currency", and its synonyms (us dollar, euros, ienes, ....).
The issue is, that the node recognizes #items:buying and #money:currency. How can I get which currency was found, and use it onto the context/output?
I tried using and also
but it always returns an empty value.
entities[0] returns me only the buying stuff, the first recognized thing. I need the second, specifically by name, in order to customize my conversation flow.
Thanks a lot.
To resolve this, first switch on #sys-currency system entity.
After that, this example should work once training is complete.
Condition: #sys-currency
Response: Currency: <? #sys-currency.unit ?>. Total: <? #sys-currency ?>
However it assumes that you are writing the currency correctly. For example:
20 USD
$20
20 dollars
More details here:
https://www.ibm.com/watson/developercloud/doc/conversation/system-entities.html#sys-currency-entity
To address the other point of finding the value of the recognised text of the entity, you would use:
<? entities[0].literal ?>

SoftLayer API Product_Package 200 getItemPrices returns mulitple (including invalid) priceIds for the same location group issueGrouID

I use the following API to get item price for item id=4281, 4.00 TB SATA disk
https://api.softlayer.com/rest/v3/SoftLayer_Product_Package
/200/getItemPrices?objectMask=mask[item,id,
locationGroupId,hourlyRecurringFee,recurringFee]&objectFilter={itemPrices:
{item:{id:{operation:*=4281}}}}
It gives two priceIds for the each same location group including invalid priceIds.
itemId=4281, locationGrouID=545, priceId=57241,68071
itemId=4281, locationGrouID=503, priceId=66971, 68063
itemId=4281, locationGrouID=505, priceId=68065, 68605
itemId=4281, locationGrouID=507, priceId=68067, 57009
itemId=4281, locationGrouID=583, priceId=153059,153159
itemId=4281, locationGrouID=509, priceId=68069,57131
itemId=4281, locationGrouID="", priceId=21209,21211
Can somebody please fix this API to make it return only single valid priceId for different locationGrouID ?
Thanks.
There is no issue the prices are different from each other, for example:
priceId=57241,68071
the priceId "57241" is valid for all disk (disk1,disk2,etc) except for the disk0, which means that you cannot use this price for the disk0 of your server. The priceId "68071" is valid only for the disk0.
The same behavior is for all the prices that you listed. In order to know which price is valid for what kind of disk you need to see the categories of the price. Try this request and you will see the categories:
https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/200/getItemPrices?objectMask=mask[categories,item,id, locationGroupId,hourlyRecurringFee,recurringFee]&objectFilter={"itemPrices": {"item":{"id":{"operation":"*=4281"}}}}
Regards

Update Product Name, Description, Short Description in Magento

The solution for this was almost provided in this answer https://stackoverflow.com/a/14249171
It does indeed replace the product name properly.
But I needed to take it a step further and check the productname, description and short description to replace 'example' with 'test' in all three areas. I wasn't sure if it was possible to modify the current script provided to include these other attributes.
this do the trick :
$newName = str_replace('example','test',$product->getName());
$product->setName($newName);
Find it and add the other attributes :
$newDescription = str_replace('example','test',$product->getDescription());
$product->setDescription($newDescription);
$newShortDescription = str_replace('example','test',$product->getShortDescription());
$product->setShortDescription($newShortDescription);
Then save each attribute like this :
$product->getResource()->saveAttribute($product,'description');
$product->getResource()->saveAttribute($product,'short_description');
Or just save the product (time and resource consuming)
$product->save();
To select only product having example in name OR description OR short_desc use this
-addAttributeToFilter(array(array('attribute'=>'name','like'=>'%example%'), array('attribute'=>'description','like'=>'%example%'),array('attribute'=>'short_description','like'=>'%example%')))
Instead of
->addAttributeToFilter('name',array('like','%example%'))

Magento Bulk update attributes

I am missing the SQL out of this to Bulk update attributes by SKU/UPC.
Running EE1.10 FYI
I have all the rest of the code working but I"m not sure the who/what/why of
actually updating our attributes, and haven't been able to find them, my logic
is
Open a CSV and grab all skus and associated attrib into a 2d array
Parse the SKU into an entity_id
Take the entity_id and the attribute and run updates until finished
Take the rest of the day of since its Friday
Here's my (almost finished) code, I would GREATLY appreciate some help.
/**
* FUNCTION: updateAttrib
*
* REQS: $db_magento
* Session resource
*
* REQS: entity_id
* Product entity value
*
* REQS: $attrib
* Attribute to alter
*
*/
See my response for working production code. Hope this helps someone in the Magento community.
While this may technically work, the code you have written is just about the last way you should do this.
In Magento, you really should be using the models provided by the code and not write database queries on your own.
In your case, if you need to update attributes for 1 or many products, there is a way for you to do that very quickly (and pretty safely).
If you look in: /app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php you will find that this controller is dedicated to updating multiple products quickly.
If you look in the saveAction() function you will find the following line of code:
Mage::getSingleton('catalog/product_action')
->updateAttributes($this->_getHelper()->getProductIds(), $attributesData, $storeId);
This code is responsible for updating all the product IDs you want, only the changed attributes for any single store at a time.
The first parameter is basically an array of Product IDs. If you only want to update a single product, just put it in an array.
The second parameter is an array that contains the attributes you want to update for the given products. For example if you wanted to update price to $10 and weight to 5, you would pass the following array:
array('price' => 10.00, 'weight' => 5)
Then finally, the third and final attribute is the store ID you want these updates to happen to. Most likely this number will either be 1 or 0.
I would play around with this function call and use this instead of writing and maintaining your own database queries.
General Update Query will be like:
UPDATE
catalog_product_entity_[backend_type] cpex
SET
cpex.value = ?
WHERE cpex.attribute_id = ?
AND cpex.entity_id = ?
In order to find the [backend_type] associated with the attribute:
SELECT
  backend_type
FROM
  eav_attribute
WHERE entity_type_id =
  (SELECT
    entity_type_id
  FROM
    eav_entity_type
  WHERE entity_type_code = 'catalog_product')
AND attribute_id = ?
You can get more info from the following blog article:
http://www.blog.magepsycho.com/magento-eav-structure-role-of-eav_attributes-backend_type-field/
Hope this helps you.