Subversion Repositories SmartDukaan

Rev

Rev 2084 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2084 Rev 2175
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# resolve links - $0 may be a softlink
-
 
3
PRG="$0"
-
 
4
if [ $# -ne 1 ]
2
if [ $# -ne 1 ]
5
then
3
then
6
    echo "Error - Invalid Arguments. Please enter itemid of ITEM table, which needs to be phased ot"
4
    echo "Error - Invalid Arguments. Please enter itemid of ITEM table, which needs to be phased out"
7
    exit
5
    exit
8
fi
6
fi
9
ITEM_ID=$1
7
ITEM_ID=$1
10
echo $ITEM_ID
8
echo $ITEM_ID
11
 
9
 
-
 
10
# resolve links - $0 may be a softlink
-
 
11
PRG="$0"
12
while [ -h "$PRG" ]; do
12
while [ -h "$PRG" ]; do
13
  ls=`ls -ld "$PRG"`
13
  ls=`ls -ld "$PRG"`
14
  link=`expr "$ls" : '.*-> \(.*\)$'`
14
  link=`expr "$ls" : '.*-> \(.*\)$'`
15
  if expr "$link" : '/.*' > /dev/null; then
15
  if expr "$link" : '/.*' > /dev/null; then
16
    PRG="$link"
16
    PRG="$link"
Line 27... Line 27...
27
 
27
 
28
echo "Updating mysql database for id $ITEM_ID"
28
echo "Updating mysql database for id $ITEM_ID"
29
echo "======================================================="
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}"
30
mysql -uroot -pshop2020 catalog -e"update item set status=0, status_description=\"This item has been phased out\" where id = ${ITEM_ID}"
31
 
31
 
32
CATALOG_ID=`mysql -uroot -pshop2020 catalog -e"select catalog_item_id from item where id = ${ITEM_ID}"`
32
CATALOG_ID=`mysql -uroot -pshop2020 catalog -e"select catalog_item_id from item where id = ${ITEM_ID}" | tail -1`
33
CATALOG_ID=`echo $CATALOG_ID | cut -c17-23`
-
 
34
#echo $CATALOG_ID
33
#echo $CATALOG_ID
35
 
34
 
36
COUNT=`mysql -uroot -pshop2020 catalog -e"select count(*) from item where catalog_item_id = ${CATALOG_ID} and status not in(0)"`
35
COUNT=`mysql -uroot -pshop2020 catalog -e"select count(*) from item where catalog_item_id = ${CATALOG_ID} and status <> 0" | tail -1`
37
COUNT=`echo $COUNT | cut -c9-20`
-
 
38
#echo $COUNT
36
#echo $COUNT
39
if [ $COUNT -le 0 ]
37
if [ -z $COUNT ]
40
then
38
then
41
echo "Not a single item is active or out of stock. Removing content from solr and removing item from website."
39
	echo "Not a single item is active or out of stock. Removing content from solr and removing item from website."
42
 
40
 
43
echo "Deleting data from solr for entity id $CATALOG_ID"
41
	echo "Deleting data from solr for entity id $CATALOG_ID"
44
echo "======================================================="
42
	echo "======================================================="
45
cd ${SOLR_DIR}
-
 
46
./deleteOne.sh $CATALOG_ID
43
	${SOLR_DIR}/deleteOne.sh $CATALOG_ID
47
echo "Done deleting data from solr for entity id $CATALOG_ID"
44
	echo "Done deleting data from solr for entity id $CATALOG_ID"
48
 
45
 
49
 
46
 
50
echo "======================================================="
47
	echo "======================================================="
51
echo "Removing content snippets for entity id $CATALOG_ID "
48
	echo "Removing content snippets for entity id $CATALOG_ID "
52
echo "======================================================="
49
	echo "======================================================="
53
cd ${CONTENT_EXPORT_PATH}
50
	cd ${CONTENT_EXPORT_PATH}
54
rm -rf entities/$CATALOG_ID
51
	rm -rf entities/$CATALOG_ID
55
echo "Done removing content for entity id $CATALOG_ID"
52
	echo "Done removing content for entity id $CATALOG_ID"
56
echo "======================================================="
53
	echo "======================================================="
57
fi
54
fi
58
 
-
 
-
 
55
#TODO If there are still some items active, we should remove color from content. Solution is to regenerate content and update it.