Ejemplo n.º 1
0
	def is_matched(self,ignoreinactive=True):
                """
		MerchantItem'in bir cimri katalog item'a matched olup olmadigini belirler

                @type  ignoreactive: bool
                @param ignoreactive: eger bu parametre dogru ise, MerchantItem'in bir itemIdsi olsa dahi eger status'u
				     PAUSED_BY_CIMRI ya da PAUSED_NO_IN_XML_ACTIVE ise matched olarak degerlendirilmez.

                @rtype: bool
                @return: MerchantItem'in matched olup olmadigi
                """

		try:
			if self.item["itemId"] in [None,""]:
				return False				
			else:
				#cimri backend includes items with itemIds with the following statuses. these are not actual matches
				#and the data is stored erronously
				if ignoreinactive is True and self.status==CimriStatus.get_status("PAUSED_NO_IN_XML_ACTIVE").get_code():
					return False
				if ignoreinactive is True and self.status==CimriStatus.get_status("PAUSED_BY_CIMRI").get_code():
					return False

				return True
					
		except Exception as e:
			pass

		return False
Ejemplo n.º 2
0
	def _add_matching_data(self,item,itemid,score,direct):
                """
		Match edilmis bir merchant item'i match ile ilgili belirli bilgiler ile gunceller

                @type  item: L{cimri.api.cimriservice.data.merchantitem.MerchantItem}
                @param item: guncellenecek item

		@type itemid: int
		@param itemid: match edilen cimri katalog item IDsi

		@type score: int
		@param score: match skoru

		@type direct: bool
		@param direct: bulunan matchin direk mi (True) ya da possible match mi oldugu

                @rtype: L{cimri.api.cimriservice.data.merchantitem.MerchantItem}
                @return: guncellenmis merchant item
                """

		item.score=score
		if itemid is not None:
			if direct:
				item.item={"itemId":itemid}
				item.status=CimriStatus.get_status("ACTIVE").get_code()
				item.matchDate=time.time()				
			else:
				item.possibleSolrItem={"itemId":itemid}
				item.status=CimriStatus.get_status("SOLR_MATCHED").get_code()

		else:
			item.status=CimriStatus.get_status("PAUSED_BY_CIMRI").get_code()

		#set operator (cron user)
		item.operator=0

		if direct:
			item.matcherType=99
		else:
			item.matcherType=999

		return item
Ejemplo n.º 3
0
	def is_guessed(self):
                """
		MerchantItem'in bir cimri katalog item ile possible matchinin olup olmadini belirler

                @rtype: bool
                @return: MerchantItem'in possible matchinin olup olmadigi
                """

		try:
			if self.possibleSolrItem["itemId"] in [None,""]:
				return False				
			else:
				if self.status==CimriStatus.get_status("SOLR_MATCHED").get_code():
					return True
				elif self.status==CimriStatus.get_status("PAUSED_NO_IN_XML_SOLR").get_code():
					return True

				return False
					
		except Exception as e:
			pass

		return False
Ejemplo n.º 4
0
	def _match_item(self,item):
                """
		Bir merchant item'i match isleminden gecirir

               	@type   item: L{cimri.api.cimriservice.data.merchantitem.MerchantItem}
               	@param  item: islemden gecirilmesi istenen merchant item

		@rtype: dict
               	@return: islem sonuclari       
                """

		#get all items for merchant
		merchant_items=yield self._get_merchant_items(item.merchant["merchantId"])
	
		#filter out items that do not have a propoer merchantItemId
		merchant_items=[it for it in merchant_items if it.merchantItemId is not None and it.merchantItemId.strip()!="" ]	

		#set if this is a zero price item or not
		item_zero_price = float(item.pricePlusTax) == 0 
		item_nonzero_price = not item_zero_price
		
		#set as 'update for price' if the item was already on the system
		item_update = None
		item_update_zero_price = None
		for it in merchant_items:
			 if it.merchantItemId==item.merchantItemId:
				item_update=it
				item_update_zero_price = it if int(it.status)==CimriStatus.get_status("PAUSED_BY_CIMRI_ZERO_PRICE").get_code() else None

		#set as new, if this is a new item
		item_new = item if item_update is None else None
		
		#update info for item
		if item_update is not None:
			#update info
			item_update.update(item)

			#update status
			item_update.status=CimriStatus(item_update.status).get_active_status().get_code()

		#if this is a new item, try finding the same merchant item by other merchants
		item_direct_match=None
		if item_new is not None:			
			item_direct_match=yield self._match_direct(item_new, merchant_items)

		#if this is a new item and direct match did not work, try matching against the catalogue
		item_insert=None
		if item_direct_match is None and item_new is not None:
			item_insert=yield self._match_merchant_item(item_new) 

		#update status for 0 price
		if item_zero_price:
			#item_update==item_zero_price
			if item_update is not None:
				item_update.status=CimriStatus.get_status("PAUSED_BY_CIMRI_ZERO_PRICE").get_code()

			#item_direct_match==item_zero_price
			if item_direct_match is not None:
				item_direct_match.status=CimriStatus.get_status("PAUSED_BY_CIMRI_ZERO_PRICE").get_code()

			#item_insert==item_zero_price
			if item_insert is not None:
				item_insert.status=CimriStatus.get_status("PAUSED_BY_CIMRI_ZERO_PRICE").get_code()

		#update status if the price became non-zero
		if item_nonzero_price:
			#item_nonzero_price==item_update_zero_price
			if item_update_zero_price is not None:			
				#if matched before, activate
				if item_update_zero_price.item is not None:
					item_update_zero_price.status=CimriStatus.get_status("ACTIVE").get_code()

				#if not matched before and automatically matched:
				elif item_update_zero_price.possibleSolrItem is not None:
					item_update_zero_price.status=CimriStatus.get_status("SOLR_MATCHED").get_code()

				#otherwise:
				else:
					item_update_zero_price.status=CimriStatus.get_status("PAUSED_BY_CIMRI").get_code()

		#make sure the merchantItemURl and pricePLusTax values are not null for items to be updated/inserted

		#return action and matched item
		item_matched=None
		action=None
		if item_update is not None:
			item_matched=item_update
			action="update"
		elif item_direct_match is not None:
			item_matched=item_direct_match
			action="match"
		elif item_insert is not None:
			item_matched=item_insert
			action="insert"
		
		defer.returnValue({"meta.action":action, "data":item_matched})