Amazon Product API: Offers from Amazon missing - amazon-product-api

I am confused how the Amazon Product API works. For my example I used this ASIN (B00Y9S4V22) which is available in the german Amazon.
I requested the data from the API with the response Group "Large,OfferFull,Offers" and was confused because the only price it returns me is "1,80". On the Amazon Page itself it shows 2,37 (orderable with Prime).
As you can see in the response below it says that there are total 3 new (In the Summary in TotalNew) - which is correct. But in the Offer Listing I only have 1 of them - the cheapest. But my goal is to get the offer which is sold by Amazon it self / prime orderable / plus-product orderable. But these offers are missing completely.
When I open the "All Offers" link I get this result:
As you can see the amazon offer is listed there - but still missing in my response.
XML Response (I removed unnecessary properties)
<Items>
<Request>
<IsValid>True</IsValid>
<ItemLookupRequest>
<Condition>All</Condition>
<IdType>ASIN</IdType>
<ItemId>B00Y9S4V22</ItemId>
<ResponseGroup>Large</ResponseGroup>
<ResponseGroup>OfferFull</ResponseGroup>
<ResponseGroup>Offers</ResponseGroup>
<VariationPage>All</VariationPage>
</ItemLookupRequest>
</Request>
<Item>
<ASIN>B00Y9S4V22</ASIN>
<ParentASIN>B01HU1G8A2</ParentASIN>
<DetailPageURL>https://www.amazon.de/Westcott-00-Geodreieck-bruchsicher-transparent/dp/B00Y9S4V22?psc=1&SubscriptionId=AKIAJAD2WJOOQC6SJGWQ&tag=cheepah-21&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00Y9S4V22</DetailPageURL>
<SalesRank>832</SalesRank>
<ItemAttributes>
<ListPrice>
<Amount>237</Amount>
<CurrencyCode>EUR</CurrencyCode>
<FormattedPrice>EUR 2,37</FormattedPrice>
</ListPrice>
</ItemAttributes>
<OfferSummary>
<LowestNewPrice>
<Amount>180</Amount>
<CurrencyCode>EUR</CurrencyCode>
<FormattedPrice>EUR 1,80</FormattedPrice>
</LowestNewPrice>
<TotalNew>3</TotalNew>
<TotalUsed>0</TotalUsed>
<TotalCollectible>0</TotalCollectible>
<TotalRefurbished>0</TotalRefurbished>
</OfferSummary>
<Offers>
<TotalOffers>1</TotalOffers>
<TotalOfferPages>1</TotalOfferPages>
<MoreOffersUrl>https://www.amazon.de/gp/offer-listing/B00Y9S4V22?SubscriptionId=AKIAJAD2WJOOQC6SJGWQ&tag=cheepah-21&linkCode=xm2&camp=2025&creative=12738&creativeASIN=B00Y9S4V22</MoreOffersUrl>
<Offer>
<Merchant>
<Name>mane Büroshop</Name>
</Merchant>
<OfferAttributes>
<Condition>New</Condition>
</OfferAttributes>
<OfferListing>
<OfferListingId>47YkU0Y7wnSskg8Uv7WqMgMXIxp3CsbATIFxuhiVJN3WRBaDRBRVgDtK4OIpe%2ByOIQQubWu4jlopsbF3uBH2AeWqyOFDpEGOLh7X%2BPjKwYsRTKgA7vy12yfzZyVVIY%2F10%2BrPSNeI24F8fo9qxj%2FLCgUdrVCFhI2a</OfferListingId>
<Price>
<Amount>180</Amount>
<CurrencyCode>EUR</CurrencyCode>
<FormattedPrice>EUR 1,80</FormattedPrice>
</Price>
<AmountSaved>
<Amount>57</Amount>
<CurrencyCode>EUR</CurrencyCode>
<FormattedPrice>EUR 0,57</FormattedPrice>
</AmountSaved>
<PercentageSaved>24</PercentageSaved>
<Availability>Versandfertig in 1 - 2 Werktagen</Availability>
<AvailabilityAttributes>
<AvailabilityType>now</AvailabilityType>
<MinimumHours>24</MinimumHours>
<MaximumHours>48</MaximumHours>
</AvailabilityAttributes>
<IsEligibleForSuperSaverShipping>0</IsEligibleForSuperSaverShipping>
<IsEligibleForPrime>0</IsEligibleForPrime>
</OfferListing>
</Offer>
</Offers>
</Item>
</Items>
And here is the Request:
<Arguments>
<Argument Name="AWSAccessKeyId" Value="---"></Argument>
<Argument Name="AssociateTag" Value="---"></Argument>
<Argument Name="Condition" Value="All"></Argument>
<Argument Name="IdType" Value="ASIN"></Argument>
<Argument Name="ItemId" Value="B00Y9S4V22"></Argument>
<Argument Name="Operation" Value="ItemLookup"></Argument>
<Argument Name="ResponseGroup" Value="Large,OfferFull,Offers"></Argument>
<Argument Name="Service" Value="AWSECommerceService"></Argument>
<Argument Name="Timestamp" Value="2018-10-30T22:14:08.000Z"></Argument>
</Arguments>
I know that there is a "ListPrice" but as far as I understand Amazon this is not always the price which is Amazon is selling it.

For anyone else who is looking for a solution:
You can also provide the argument "MerchantId" and set it to "Amazon". I am still confused why not all Offers are listed but when setting the argument "MerchantId" the response will provide the Amazon Offer (but no offer else)

Related

cts:near-query Marklogic on json documents

I am using search:search like below
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<concurrency-level>8</concurrency-level>
<search-option>unfiltered</search-option>
<transform-results apply="empty-snippet">
<!-- #apply=snippet : to get snippet-->
<per-match-tokens>30</per-match-tokens>
<max-matches>4</max-matches>
<max-snippet-chars>200</max-snippet-chars>
<preferred-matches/>
</transform-results>
<term>
<term-option>case-insensitive</term-option>
<term-option>wildcarded</term-option>
<term-option>stemmed</term-option>
<term-option>diacritic-insensitive</term-option>
<term-option>punctuation-insensitive</term-option>
</term>
<constraint name="title">
<range collation="http://marklogic.com/collation/codepoint" type="xs:string" facet="false">
<json-property>title</json-property>
</range>
</constraint>
<extract-document-data>
<!-- Full Title -->
<extract-path>/title</extract-path>
</extract-document-data>
<additional-query>
<cts:near-query distance="1" xmlns:cts="http://marklogic.com/cts">
<cts:json-property-word-query>
<cts:property>title</cts:property>
<cts:text xml:lang="en">chemotherapy</cts:text>
<cts:option>case-insensitive</cts:option>
</cts:json-property-word-query>
<cts:json-property-word-query>
<cts:property>title</cts:property>
<cts:text xml:lang="en">hospital</cts:text>
<cts:option>case-insensitive</cts:option>
</cts:json-property-word-query>
<cts:option>ordered</cts:option>
</cts:near-query>
</additional-query>
<additional-query/>
</options>
return
search:search('', $query, 1, 10)
Using this query I am getting the document with title, in the query distance between chemotherapy and hospital in 1
Result with title :{"title":"chemotherapy for cancer patients in the hospital."}
Am I doing something wrong?
Thanks
It worked after enabling the word position index in Db settings

How to create a custom system field in magento 1?

Magento 1.9
I want to create a new tab in System > Configuration.
In this tab, I need a group tab and in this group tab i want a textarea which is connected to a field of my database. If i edit my textarea, it will modify my database field too.
Look at this: https://prnt.sc/orwph1
I don't know how to connect my textarea with my db.. Create a new tab with a new group it's easy but connect it to the db..
Thanks!
let's assume you want a section that has 2 fields: multiselect, text area. In the multiselect you have all your customer and in the text are you get the modify to apply for a certain db field (related to the customer).
your system.xml should me something like this:
<config>
<tabs>
<admin_customTab_2 translate="label" module="sections">
<label>- TAB NAME -</label>
<sort_order>2</sort_order>
</admin_customTab_2>
</tabs>
<sections>
<customsection2 translate="label" module="sections">
<label>label name</label>
<tab>admin_customTab_2</tab>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<block translate="label">
<label>label name</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<block_customers>
<label>Select user</label>
<comment>user list</comment>
<frontend_type>multiselect</frontend_type>
<backend_model>sections/users</backend_model>
<source_model>sections/users</source_model> <!-- adding a source-model for the form's select -->
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</block_customers>
<block_textarea>
<label>changes to apply</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</block_textarea>
</fields>
</block>
</groups>
</customsection2>
</sections>
this is not enough for the configs, you need to tell Magento about the access control list (ACL) or admin-users will not see it. It is done in the config.xml
like this:
<adminhtml>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<customsection2>
<title>Customer Changes?</title>
</customsection2>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</adminhtml>
all is setted, but doing nothing but showing us the tabs and forms.
If you was brave enough you noticed a tag in the system.xml code up here,
<backend_model>sections/users</backend_model>
<source_model>sections/users</source_model> <!-- adding a source-model for the form's select -->
this tell magento that you are using a model relating to this form, where you can do operations.
So, in your Model's path create the (in this example) User.php
and here we go:
you want to extend your custom class with this one.
class Admin_Sections_Model_Users extends Mage_Core_Model_Config_Data
yes but we still didn't insert any data in the form.
You can do this by just adding a special function toOptionArray() :
public function toOptionArray()
{
$collections = Mage::getModel("customer/customer")->getCollection();
foreach ($collections as $colletion){
$user = Mage::getModel("customer/customer")->load($colletion->getId());
$array[] = array('value'=>$user->getEntityId(),'label'=>Mage::helper("sections")->__($user->getName()));
}
return $array ;
}
this will set ALL the customer's name into the multi-select form.
"yeah, nice.. I asked about the text-area"
before telling you how to get Data from Store Configs, you should know that there are 2 main methods for elaborating the form data:
public function _afterSave()
{}
public function _beforeSave()
{}
in there you can put all your code, no need to explain what is the difference between them.
in this function you can easy get the Data from Store Config by doing:
$text_area_string = Mage::getStoreConfig('customsection2/block/block_textarea');
"yeah nice... but my main problem is to save things in DB"
you can use whenever you prefer the Mage::getModel('') method , this can connect you to the database. Lets make an example; modify the 'is_active' field on 'customer_entity' table.
$customer = Mage::getModel("customer/customer")->load($customer_id);
$customer->setData("is_active",0);
$customer->save();
this field doesn't do really anything, it is just a very fast example.
This should let you do what you are aiming for.
If something sounds strange, please let me know!

BIML: automatic creation of OleDbDestinations for XMLSource in Dataflow

I'm having a XML file with 2 outputpaths and 2 tables in my staging DB. Tables and outputpaths do have same names.
Instead of writing 2 times OleDbDestination and changing Inputpath and ExternalTableOutput I would like to use some Bimlscript.
My current solution:
<Dataflow Name="DF_MyXml">
<Transformations>
<XmlSource Name="MyXml">
<FileInput ConnectionName="simple.xml" />
<XmlSchemaFileInput ConnectionName="simple.xsd" />
</XmlSource>
<OleDbDestination Name="Database" ConnectionName="Dest">
<InputPath OutputPathName = "MyXml.Database" />
<ExternalTableOutput Table="Database" />
</OleDbDestination>
<OleDbDestination Name="Project" ConnectionName="Dest">
<InputPath OutputPathName = "MyXml.Project" />
<ExternalTableOutput Table="Project" />
</OleDbDestination>
</Transformations>
</Dataflow>
What I would like to achive:
<Dataflow Name="DF_MyXML">
<Transformations>
<XmlSource Name="MyXml">
<FileInput ConnectionName="simple.xml" />
<XmlSchemaFileInput ConnectionName="simple.xsd" />
</XmlSource>
<#foreach (var OutP in ["myXML"].DataflowOutputs) { #>
<OleDbDestination Name="<#=OutP.Name#>" ConnectionName="Dest">
<InputPath OutputPathName = "MyXml.<#=OutP.Name#>" />
<ExternalTableOutput Table="<#=OutP.Name#>" />
</OleDbDestination>
<# } #>
</Transformations>
</Dataflow>
Sadly this isn't working. ;-)
In API-Documentation for AstXMLSourceNode I found the property "DataflowOutputs" which "Gets a collection of all dataflow output paths for this transformation" (sounds promising, uhh?) but I can't even figure out how to reference the XMLSource in Bimlscript in any way.
Starting from RootNode I was able to find my Dataflow-Task but then I got stuck and didn't manage to "find" my Transformations\XMLSource.
Any help would be much appreciated!!
BTW: if there is a solution to automatically create destination-tables based on a given XSD this would be greate too. :-)
You need to make sure your connections are declared in a separate file to be easily accessed in Biml script. You can mess with Console.WriteLine() to print out details about objects to the output window and get a glimpse of what is going on in the BimlScript.
In the second file, traditionally called Environmnet.biml,
you need (only with your xml file connection info, the data here is just a placeholder):
<Connections>
<FileConnection Name="XmlFile" FilePath="C:\test\XmlFile.xml" RelativePath="true" />
<FileConnection Name="XmlXsd" FilePath="C:\test\XmlXsd.Xsd" RelativePath="true" />
</Connections>
then you can do something to the effect of :
var fileConnection = RootNode.Connections["XmlFile"];
(sorry before I accidentally put DbConnections)
and play with it from there. I do not have any xml files at my disposal right now to play around with to help you get the exact information that you are looking for. I will update on Monday.

gContact namespace not working

I am trying to POST contact data to GContact to create a new contact. I can create a new contact if I use only "gd" XML elements, but when I try and post a "gContact" element it gives me an error. I'm sure it's something simple because I am a total amateur, but I would appreciate any help.
This works
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
<gd:name>
<gd:givenName>Jack</gd:givenName>
<gd:familyName>Masters</gd:familyName>
<gd:fullName>Jack Masters</gd:fullName>
<gd:additionalName>Rascal</gd:additionalName>
<gd:namePrefix>Sir</gd:namePrefix>
<gd:nameSuffix>II</gd:nameSuffix>
</gd:name>
<atom:content type="text">These are some testing notes.</atom:content>
<gd:email rel="http://schemas.google.com/g/2005#work" address="newtestAddress#gmail.com" primary="true" />
<gd:phoneNumber rel="http://schemas.google.com/g/2005#home" primary="true">716-999-0098</gd:phoneNumber>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#work">666-8765-9087</gd:phoneNumber>
<gd:structuredPostalAddress rel="http://schemas.google.com/g/2005#home">
<gd:formattedAddress>3546 Madison Street, Chicago IL, 56879</gd:formattedAddress>
<gd:street>3546 Madison Street</gd:street>
<gd:city>Chicago</gd:city>
<gd:state>IL</gd:state>
<gd:country>USA</gd:country>
</gd:structuredPostalAddress>
</atom:entry>
But this doesn't
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
<gd:name>
<gd:givenName>Jack</gd:givenName>
<gd:familyName>Masters</gd:familyName>
<gd:fullName>Jack Masters</gd:fullName>
<gd:additionalName>Rascal</gd:additionalName>
<gd:namePrefix>Sir</gd:namePrefix>
<gd:nameSuffix>II</gd:nameSuffix>
</gd:name>
<atom:content type="text">These are some testing notes.</atom:content>
<gd:email rel="http://schemas.google.com/g/2005#work" address="newtestAddress#gmail.com" primary="true" />
<gd:email rel="http://schemas.google.com/g/2005#home" address="evenNewerAddress#yahoo.com" />
<gd:phoneNumber rel="http://schemas.google.com/g/2005#home" primary="true">716-999-0098</gd:phoneNumber>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#work">666-8765-9087</gd:phoneNumber>
<gd:structuredPostalAddress rel="http://schemas.google.com/g/2005#home">
<gd:formattedAddress>3546 Madison Street, Chicago IL, 56879</gd:formattedAddress>
<gd:street>3546 Madison Street</gd:street>
<gd:city>Chicago</gd:city>
<gd:state>IL</gd:state>
<gd:country>USA</gd:country>
</gd:structuredPostalAddress>
<gContact:groupMembershipInfo href="http://www.google.com/m8/feeds/groups/default/base/14b3e56788eb41b8" />
</atom:entry>
I have tried a number of different gContact elements and nothing seems to work. I get a 400 HTTP response code every time.
This is the response detail. I can't seem to figure where the error is.
Optional(<NSHTTPURLResponse: 0x600000234480> { URL: https://www.google.com/m8/feeds/contacts/default/full?alt=json } { status code: 400, headers {
"Cache-Control" = "private, max-age=0";
"Content-Encoding" = gzip;
"Content-Type" = "text/plain; charset=UTF-8";
Date = "Tue, 07 Mar 2017 16:02:17 GMT";
Expires = "Tue, 07 Mar 2017 16:02:17 GMT";
Server = GSE;
"alt-svc" = "quic=\":443\"; ma=2592000; v=\"36,35,34\"";
"x-content-type-options" = nosniff;
"x-frame-options" = SAMEORIGIN;
"x-xss-protection" = "1; mode=block"; } })
You may want to try these recommended actions for error code 400 as given in Standard Error Responses:
invalidParameter
Do not retry without fixing the problem. You need to provide a valid value for the parameter specified in the error response.
badRequest
Do not retry without fixing the problem. You need to make changes to the API query in order for it to work.
You may want to also check this related SO post for additional insights that might help you.
I figured it out. I was literally formatting every gContact element that I was trying incorrectly. I had tried 4 separate things and wrongly assumed it was something contextual I hadn't set. In reality I had formatted all four wrong in different ways. New programmer lesson learned.

SLD - place label on each multipoint

I have a multipoint geometry (a single geometry containing multiple points) and I want to place a label on each of the points (the label is always the same). Is it possible to achieve this with SLD? Right now the label is only displayed on a single point.
My SLD looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>Multipoint with labels</Name>
<UserStyle>
<Title>Default Point</Title>
<Abstract>A sample style that draws a point</Abstract>
<FeatureTypeStyle>
<Rule>
<Name>rule1</Name>
<Title>Red Square</Title>
<Abstract>A 6 pixel square with a red fill and no stroke</Abstract>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>square</WellKnownName>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
</Fill>
</Mark>
<Size>6</Size>
</Graphic>
</PointSymbolizer>
<TextSymbolizer>
<Label>NAME</Label>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
By default the GeoServer label engine goes to a lot of trouble to not label multiple times on the same feature, so this is hard!
I finally managed it using the following (ugly) SLD:
<Rule>
<Title>Capitals</Title>
<TextSymbolizer>
<Geometry>
<ogc:Function name="getGeometryN">
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Literal>0</ogc:Literal>
</ogc:Function>
</Geometry>
<Label>ID</Label>
</TextSymbolizer>
<TextSymbolizer>
<Geometry>
<ogc:Function name="getGeometryN">
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
</ogc:Function>
</Geometry>
<Label>ID</Label>
</TextSymbolizer>
<TextSymbolizer>
<Geometry>
<ogc:Function name="getGeometryN">
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Literal>2</ogc:Literal>
</ogc:Function>
</Geometry>
<Label>ID</Label>
</TextSymbolizer>
<TextSymbolizer>
<Geometry>
<ogc:Function name="getGeometryN">
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Literal>3</ogc:Literal>
</ogc:Function>
</Geometry>
<Label>ID</Label>
</TextSymbolizer>
</Rule>
However this assumes you know how many points there are in your largest multi-point, and that is quite small (otherwise it's a lot of copy & paste).
I had originally hoped to be able to use the vertices function or possibly the labelAllGroup vendor option, but sadly neither worked with multi-points.