Rev 2175 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/bashif [ $# -ne 1 ]thenecho "Error - Invalid Arguments. Please enter itemid of ITEM table, which needs to be phased out"exitfiITEM_ID=$1echo $ITEM_ID# resolve links - $0 may be a softlinkPRG="$0"while [ -h "$PRG" ]; dols=`ls -ld "$PRG"`link=`expr "$ls" : '.*-> \(.*\)$'`if expr "$link" : '/.*' > /dev/null; thenPRG="$link"elsePRG=`dirname "$PRG"`/"$link"fidone# Get standard environment variablesPRGDIR=`dirname $(readlink -f "$PRG")`SOLR_DIR=/root/solr/example/exampledocsCONTENT_EXPORT_PATH="/var/lib/tomcat6/webapps/export/html/"echo "Updating mysql database for id $ITEM_ID"echo "======================================================="mysql -uroot -pshop2020 catalog -e"update item set status=0, status_description=\"This item has been phased out\" where id = ${ITEM_ID}"CATALOG_ID=`mysql -uroot -pshop2020 catalog -e"select catalog_item_id from item where id = ${ITEM_ID}" | tail -1`#echo $CATALOG_IDCOUNT=`mysql -uroot -pshop2020 catalog -e"select count(*) from item where catalog_item_id = ${CATALOG_ID} and status <> 0" | tail -1`#echo $COUNTif [ -z $COUNT ]thenecho "Not a single item is active or out of stock. Removing content from solr and removing item from website."echo "Deleting data from solr for entity id $CATALOG_ID"echo "======================================================="${SOLR_DIR}/deleteOne.sh $CATALOG_IDecho "Done deleting data from solr for entity id $CATALOG_ID"echo "======================================================="echo "Removing content snippets for entity id $CATALOG_ID "echo "======================================================="cd ${CONTENT_EXPORT_PATH}rm -rf entities/$CATALOG_IDecho "Done removing content for entity id $CATALOG_ID"echo "======================================================="fi#TODO If there are still some items active, we should remove color from content. Solution is to regenerate content and update it.