Subversion Repositories SmartDukaan

Rev

Rev 2175 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2084 rajveer 1
#!/bin/bash
2
if [ $# -ne 1 ]
3
then
2175 rajveer 4
    echo "Error - Invalid Arguments. Please enter itemid of ITEM table, which needs to be phased out"
2084 rajveer 5
    exit
6
fi
7
ITEM_ID=$1
8
echo $ITEM_ID
9
 
2175 rajveer 10
# resolve links - $0 may be a softlink
11
PRG="$0"
2084 rajveer 12
while [ -h "$PRG" ]; do
13
  ls=`ls -ld "$PRG"`
14
  link=`expr "$ls" : '.*-> \(.*\)$'`
15
  if expr "$link" : '/.*' > /dev/null; then
16
    PRG="$link"
17
  else
18
    PRG=`dirname "$PRG"`/"$link"
19
  fi
20
done
21
 
22
# Get standard environment variables
23
PRGDIR=`dirname $(readlink -f "$PRG")`
24
 
13031 manish.sha 25
SOLR_DIR=/root/solr/example/exampledocs
2084 rajveer 26
CONTENT_EXPORT_PATH="/var/lib/tomcat6/webapps/export/html/"
27
 
28
echo "Updating mysql database for id $ITEM_ID"
29
echo "======================================================="
30
mysql -uroot -pshop2020 catalog -e"update item set status=0, status_description=\"This item has been phased out\" where id = ${ITEM_ID}"
31
 
2175 rajveer 32
CATALOG_ID=`mysql -uroot -pshop2020 catalog -e"select catalog_item_id from item where id = ${ITEM_ID}" | tail -1`
2084 rajveer 33
#echo $CATALOG_ID
34
 
2175 rajveer 35
COUNT=`mysql -uroot -pshop2020 catalog -e"select count(*) from item where catalog_item_id = ${CATALOG_ID} and status <> 0" | tail -1`
2084 rajveer 36
#echo $COUNT
2175 rajveer 37
if [ -z $COUNT ]
2084 rajveer 38
then
2175 rajveer 39
	echo "Not a single item is active or out of stock. Removing content from solr and removing item from website."
2084 rajveer 40
 
2175 rajveer 41
	echo "Deleting data from solr for entity id $CATALOG_ID"
42
	echo "======================================================="
43
	${SOLR_DIR}/deleteOne.sh $CATALOG_ID
44
	echo "Done deleting data from solr for entity id $CATALOG_ID"
2084 rajveer 45
 
46
 
2175 rajveer 47
	echo "======================================================="
48
	echo "Removing content snippets for entity id $CATALOG_ID "
49
	echo "======================================================="
50
	cd ${CONTENT_EXPORT_PATH}
51
	rm -rf entities/$CATALOG_ID
52
	echo "Done removing content for entity id $CATALOG_ID"
53
	echo "======================================================="
2084 rajveer 54
fi
2175 rajveer 55
#TODO If there are still some items active, we should remove color from content. Solution is to regenerate content and update it.