def amazonbarcodesearch(list, mkt, idtype):
    '''
    
    :param list: list of barcodes to search inside Amazon
    :param mkt: Marketplace ID
    :param idtype: Barcode Type, EG UPC, EAN
    :return: List of results

    Amazon Marketplace	MarketplaceId
    DE	                A1PA6795UKMFR9
    ES	                A1RKKUPIHCS9HS
    FR	                A13V1IB3VIYZZH
    IT	                APJ6JRA9NG5V4
    UK	                A1F83G8C2ARO7P
    
    '''

    counter = 1
    results = []
    # Provide credentials
    conn = MWSConnection(
        aws_access_key_id="",  #add your access_key_id
        aws_secret_access_key="",  #add your secret_access_key
        Merchant="",  #add your merchant id
        host=""  #add your host
    )

    while len(list) > 0:
        # Get a list of orders.
        response = conn.get_matching_product_for_id(
            IdType=idtype,
            # Can only search 5 barcodes at a time
            IdList=list[0:5],
            MarketplaceId=mkt)

        product = response.GetMatchingProductForIdResult
        print(product)

        for value in product:
            status = value['status']
            barcode = value['Id']

            if status != 'Success':
                results.append(
                    "There is no matching Amazon product for item with {}: {}".
                    format(idtype, barcode))
            else:
                itemtitle = unidecode(value.Products.Product[0].AttributeSets.
                                      ItemAttributes[0].Title)
                asin = value.Products.Product[
                    0].Identifiers.MarketplaceASIN.ASIN
                results.append(
                    "Found match for Linnworks Item: {}.  {}: {} with matching ASIN: {}"
                    .format(itemtitle, idtype, barcode, asin))

        list = list[5:]
        counter += 1

    return results
Esempio n. 2
0
class MWSTestCase(unittest.TestCase):
    def setUp(self):
        self.mws = MWSConnection(Merchant=simple, debug=0)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_feedlist(self):
        self.mws.get_feed_submission_list()

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_inbound_status(self):
        response = self.mws.get_inbound_service_status()
        status = response.GetServiceStatusResult.Status
        self.assertIn(status, ('GREEN', 'GREEN_I', 'YELLOW', 'RED'))

    @property
    def marketplace(self):
        try:
            return self._marketplace
        except AttributeError:
            response = self.mws.list_marketplace_participations()
            result = response.ListMarketplaceParticipationsResult
            self._marketplace = result.ListMarketplaces.Marketplace[0]
            return self.marketplace

    @property
    def marketplace_id(self):
        return self.marketplace.MarketplaceId

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_marketplace_participations(self):
        response = self.mws.list_marketplace_participations()
        result = response.ListMarketplaceParticipationsResult
        self.assertTrue(result.ListMarketplaces.Marketplace[0].MarketplaceId)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_product_categories_for_asin(self):
        asin = '144930544X'
        response = self.mws.get_product_categories_for_asin(
            MarketplaceId=self.marketplace_id, ASIN=asin)
        self.assertEqual(len(response._result.Self), 3)
        categoryids = [x.ProductCategoryId for x in response._result.Self]
        self.assertSequenceEqual(categoryids, ['285856', '21', '491314'])

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_list_matching_products(self):
        response = self.mws.list_matching_products(
            MarketplaceId=self.marketplace_id, Query='boto')
        products = response._result.Products
        self.assertTrue(len(products))

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_matching_product(self):
        asin = 'B001UDRNHO'
        response = self.mws.get_matching_product(
            MarketplaceId=self.marketplace_id, ASINList=[asin])
        attributes = response._result[0].Product.AttributeSets.ItemAttributes
        self.assertEqual(attributes[0].Label, 'Serengeti')

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_matching_product_for_id(self):
        asins = ['B001UDRNHO', '144930544X']
        response = self.mws.get_matching_product_for_id(
            MarketplaceId=self.marketplace_id, IdType='ASIN', IdList=asins)
        self.assertEqual(len(response._result), 2)
        for result in response._result:
            self.assertEqual(len(result.Products.Product), 1)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_lowest_offer_listings_for_asin(self):
        asin = '144930544X'
        response = self.mws.get_lowest_offer_listings_for_asin(
            MarketplaceId=self.marketplace_id,
            ItemCondition='New',
            ASINList=[asin])
        listings = response._result[0].Product.LowestOfferListings
        self.assertTrue(len(listings.LowestOfferListing))

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_list_inventory_supply(self):
        asof = (datetime.today() - timedelta(days=30)).isoformat()
        response = self.mws.list_inventory_supply(QueryStartDateTime=asof,
                                                  ResponseGroup='Basic')
        self.assertTrue(hasattr(response._result, 'InventorySupplyList'))
Esempio n. 3
0
class MWSTestCase(unittest.TestCase):

    def setUp(self):
        self.mws = MWSConnection(Merchant=simple, debug=0)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_feedlist(self):
        self.mws.get_feed_submission_list()

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_inbound_status(self):
        response = self.mws.get_inbound_service_status()
        status = response.GetServiceStatusResult.Status
        self.assertIn(status, ('GREEN', 'GREEN_I', 'YELLOW', 'RED'))

    @property
    def marketplace(self):
        response = self.mws.list_marketplace_participations()
        result = response.ListMarketplaceParticipationsResult
        return result.ListMarketplaces.Marketplace[0]

    @property
    def marketplace_id(self):
        return self.marketplace.MarketplaceId

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_marketplace_participations(self):
        response = self.mws.list_marketplace_participations()
        result = response.ListMarketplaceParticipationsResult
        self.assertTrue(result.ListMarketplaces.Marketplace[0].MarketplaceId)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_product_categories_for_asin(self):
        asin = '144930544X'
        response = self.mws.get_product_categories_for_asin(
            MarketplaceId=self.marketplace_id,
            ASIN=asin)
        result = response._result
        self.assertTrue(int(result.Self.ProductCategoryId) == 21)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_list_matching_products(self):
        response = self.mws.list_matching_products(
            MarketplaceId=self.marketplace_id,
            Query='boto')
        products = response._result.Products
        self.assertTrue(len(products))

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_matching_product(self):
        asin = 'B001UDRNHO'
        response = self.mws.get_matching_product(
            MarketplaceId=self.marketplace_id,
            ASINList=[asin])
        attributes = response._result[0].Product.AttributeSets.ItemAttributes
        self.assertEqual(attributes[0].Label, 'Serengeti')

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_matching_product_for_id(self):
        asins = ['B001UDRNHO', '144930544X']
        response = self.mws.get_matching_product_for_id(
            MarketplaceId=self.marketplace_id,
            IdType='ASIN',
            IdList=asins)
        self.assertEqual(len(response._result), 2)
        for result in response._result:
            self.assertEqual(len(result.Products.Product), 1)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_lowest_offer_listings_for_asin(self):
        asin = '144930544X'
        response = self.mws.get_lowest_offer_listings_for_asin(
            MarketplaceId=self.marketplace_id,
            ItemCondition='New',
            ASINList=[asin])
        listings = response._result[0].Product.LowestOfferListings
        self.assertTrue(len(listings.LowestOfferListing))

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_list_inventory_supply(self):
        asof = (datetime.today() - timedelta(days=30)).isoformat()
        response = self.mws.list_inventory_supply(QueryStartDateTime=asof,
                                                  ResponseGroup='Basic')
        self.assertTrue(hasattr(response._result, 'InventorySupplyList'))
Esempio n. 4
0
#print variants

#variants = [190528763294, 190528763379]

print type(variants)
x = 0
records = len(variants)
for variant in variants:
    SKU = [variant[0]]
    print '--------------------------------------------'
    print SKU
    time.sleep(.1)
    try:
        result = conn.get_matching_product_for_id(MarketplaceId=marketplaceId,
                                                  IdType="UPC",
                                                  IdList=SKU)
        #print result
        asin = result.GetMatchingProductForIdResult[0].Products.Product[
            0].Identifiers.MarketplaceASIN.ASIN
        #	print asin
        #print '1 Row Uploaded: ' + UPC  + '|' + SKU[0]
        try:
            sql = "insert into Staging AMAZON UPC values ('%s','%s')" % (
                SKU[0], asin)
            tera.upload(sql)
        except:
            print "Duplicate Error"
    #	print sql

    except:
Esempio n. 5
0
File: test.py Progetto: Kixeye/boto
class MWSTestCase(unittest.TestCase):
    def setUp(self):
        self.mws = MWSConnection(Merchant=simple, debug=0)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_feedlist(self):
        self.mws.get_feed_submission_list()

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_inbound_status(self):
        response = self.mws.get_inbound_service_status()
        status = response.GetServiceStatusResult.Status
        self.assertIn(status, ("GREEN", "GREEN_I", "YELLOW", "RED"))

    @property
    def marketplace(self):
        try:
            return self._marketplace
        except AttributeError:
            response = self.mws.list_marketplace_participations()
            result = response.ListMarketplaceParticipationsResult
            self._marketplace = result.ListMarketplaces.Marketplace[0]
            return self.marketplace

    @property
    def marketplace_id(self):
        return self.marketplace.MarketplaceId

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_marketplace_participations(self):
        response = self.mws.list_marketplace_participations()
        result = response.ListMarketplaceParticipationsResult
        self.assertTrue(result.ListMarketplaces.Marketplace[0].MarketplaceId)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_product_categories_for_asin(self):
        asin = "144930544X"
        response = self.mws.get_product_categories_for_asin(MarketplaceId=self.marketplace_id, ASIN=asin)
        self.assertEqual(len(response._result.Self), 3)
        categoryids = [x.ProductCategoryId for x in response._result.Self]
        self.assertSequenceEqual(categoryids, ["285856", "21", "491314"])

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_list_matching_products(self):
        response = self.mws.list_matching_products(MarketplaceId=self.marketplace_id, Query="boto")
        products = response._result.Products
        self.assertTrue(len(products))

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_matching_product(self):
        asin = "B001UDRNHO"
        response = self.mws.get_matching_product(MarketplaceId=self.marketplace_id, ASINList=[asin])
        attributes = response._result[0].Product.AttributeSets.ItemAttributes
        self.assertEqual(attributes[0].Label, "Serengeti")

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_matching_product_for_id(self):
        asins = ["B001UDRNHO", "144930544X"]
        response = self.mws.get_matching_product_for_id(MarketplaceId=self.marketplace_id, IdType="ASIN", IdList=asins)
        self.assertEqual(len(response._result), 2)
        for result in response._result:
            self.assertEqual(len(result.Products.Product), 1)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_lowest_offer_listings_for_asin(self):
        asin = "144930544X"
        response = self.mws.get_lowest_offer_listings_for_asin(
            MarketplaceId=self.marketplace_id, ItemCondition="New", ASINList=[asin]
        )
        listings = response._result[0].Product.LowestOfferListings
        self.assertTrue(len(listings.LowestOfferListing))

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_list_inventory_supply(self):
        asof = (datetime.today() - timedelta(days=30)).isoformat()
        response = self.mws.list_inventory_supply(QueryStartDateTime=asof, ResponseGroup="Basic")
        self.assertTrue(hasattr(response._result, "InventorySupplyList"))
Esempio n. 6
0
File: test.py Progetto: 2mind/boto
class MWSTestCase(unittest.TestCase):

    def setUp(self):
        self.mws = MWSConnection(Merchant=simple, debug=0)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_feedlist(self):
        self.mws.get_feed_submission_list()

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_inbound_status(self):
        response = self.mws.get_inbound_service_status()
        status = response.GetServiceStatusResult.Status
        self.assertIn(status, ('GREEN', 'GREEN_I', 'YELLOW', 'RED'))

    @property
    def marketplace(self):
        response = self.mws.list_marketplace_participations()
        result = response.ListMarketplaceParticipationsResult
        return result.ListMarketplaces.Marketplace[0]

    @property
    def marketplace_id(self):
        return self.marketplace.MarketplaceId

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_marketplace_participations(self):
        response = self.mws.list_marketplace_participations()
        result = response.ListMarketplaceParticipationsResult
        self.assertTrue(result.ListMarketplaces.Marketplace[0].MarketplaceId)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_product_categories_for_asin(self):
        asin = '144930544X'
        response = self.mws.get_product_categories_for_asin(\
            MarketplaceId=self.marketplace_id,
            ASIN=asin)
        result = response._result
        self.assertTrue(int(result.Self.ProductCategoryId) == 21)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_list_matching_products(self):
        response = self.mws.list_matching_products(\
            MarketplaceId=self.marketplace_id,
            Query='boto')
        products = response._result.Products
        self.assertTrue(len(products))

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_matching_product(self):
        asin = 'B001UDRNHO'
        response = self.mws.get_matching_product(\
            MarketplaceId=self.marketplace_id,
            ASINList=[asin,])
        product = response._result[0].Product

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_matching_product_for_id(self):
        asins = ['B001UDRNHO', '144930544X']
        response = self.mws.get_matching_product_for_id(\
            MarketplaceId=self.marketplace_id,
            IdType='ASIN',
            IdList=asins)
        self.assertEqual(len(response._result), 2)
        for result in response._result:
            self.assertEqual(len(result.Products.Product), 1)

    @unittest.skipUnless(simple and isolator, "skipping simple test")
    def test_get_lowest_offer_listings_for_asin(self):
        asin = '144930544X'
        response = self.mws.get_lowest_offer_listings_for_asin(\
            MarketplaceId=self.marketplace_id,
            ItemCondition='New',
            ASINList=[asin,])
        product = response._result[0].Product
        self.assertTrue(product.LowestOfferListings)
Esempio n. 7
0
group by 1,2
 ''' )
#and m.amz_asin = 'B01MQIXH3T'

#print ASINLIST        
x = 0
records = len(ASINLIST)
for item in ASINLIST:
    
    print '----------------------------------------------------'
    print item
    ASIN = [item[0]]
    RetailVariantID = item[1]
    print ASIN[0]
    
    parent = conn.get_matching_product_for_id(MarketplaceId=marketplaceId,IdType="ASIN",IdList=ASIN)
    try:
        parent = parent.GetMatchingProductForIdResult[0].Products.Product[0].Relationships.VariationParent[0].Identifiers
        parent = [parent.MarketplaceASIN.ASIN]
    except:
        parent = ASIN

    print 'Parent ASIN: ' + str(parent[0])

    try:
        slsrank = conn.get_matching_product_for_id(MarketplaceId=marketplaceId,IdType="ASIN",IdList=parent)
        title =  slsrank.GetMatchingProductForIdResult[0].Products.Product[0].AttributeSets.ItemAttributes[0].Title
    except:
        title = 'FAIL'
    try:
        slsrank = slsrank.GetMatchingProductForIdResult[0].Products.Product[0].SalesRankings.SalesRank[0].Rank