# download debian 32 bit domU installer wget http://ftp.debian.org/debian/dists/squeeze/main/installer-i386/current/images/netboot/xen/initrd.gz -O /tmp/initrd.gz wget http://ftp.debian.org/debian/dists/squeeze/main/installer-i386/current/images/netboot/xen/vmlinuz -O vmlinuz # create lvm for domU lvcreate --name oracle-disk --size 16G vg1 lvcreate --name oracle-swap --size 16G vg1 # create domU config for installation cat <<EOF> /etc/xen/oracle kernel = '/tmp/vmlinuz' ramdisk = '/tmp/initrd.gz' vcpus = '2' memory = '2048' root = '/dev/xvda2 ro' di
# install apps apt-get -y install build-essential e2fslibs-dev # download wget http://kent.dl.sourceforge.net/project/extundelete/extundelete/0.2.0/extundelete-0.2.0.tar.bz2 -P /tmp # extract tar xjf /tmp/extundelete-0.2.0.tar.bz2 -C /tmp # compile cd /tmp/extundelete-0.2.0 ./configure make # make install # restore files /tmp/extundelete-0.2.0/src/extundelete /dev/sdc1 --restore-all
# create a new file ./getProductEn.php <?php require '../../app/Mage.php'; try { $app = Mage::app('gb'); // check sku $sku = $_GET['sku']; if(!empty($sku)) { // filter char in sku $sku = preg_replace("/[^a-zA-Z0-9-\s]/", "", $sku); // get product by sku $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku); if($product != null) { header('Location: '. $product->getProductUrl() .
# install lxc
sudo apt-get install -y lxc
# OPTIONAL
# sudo apt-get install -y bridge-utils libvirt-bin debootstrap
# configure fs
sudo echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab
sudo mount -a
# create vm
sudo lxc-create -n vm1 -t debian
# lxc-create -n foo -f lxc.conf
# fix language configuration
cat << EOF | sudo tee /var/lib/lxc/vm1/rootfs/etc/environment
LANGUAGE=en_US.UTF-8
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
LC_CTYPE=C
EOF
cat << EOF | sudo tee /etc/default/locale
LANG="en_US.UTF-8"
EOF
# start vm
./app/design/frontend/default/default/template/catalog/product/featured.phtml
<?php
$categoryId = 2228;
$catagory_model = Mage::getModel('catalog/category')->load($categoryId);
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addCategoryFilter($catagory_model);
$collection->addAttributeToFilter('status', 1);
// $collection->addAttributeToSelect(array('name','url','small_image')); //add product attribute to be fetched
$collection->getSelect()->order('rand()');
$collection->addStoreFilter();
$collection->setPageSize(1);
$collection->setCurPage(1);
if(!empty($collection)) {
foreach ($collection as $_product) {
$_product = Mage::getModel('catalog/product')->setStoreId($this->store_id)->load($_product->getId());
?>
<div class="featured_item" style="text-align: center;">
<?php echo "<!-- <sku>" . $_product->getSku() . "</sku> -->"; ?>
<div class="featured-product-name" >
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="red">
<strong><?php echo utf8_decode($this->htmlEscape($_product->getName())); ?></strong>
</a>
</div>
<br>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo utf8_decode($this->htmlEscape($_product->getName())); ?>">
<img class="product-image" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(250, 125); ?>" width="250" height="125" alt="<?php echo utf8_decode($this->htmlEscape($_product->getName())); ?>" />
</a>
<div class="featured-product-name">
<?php echo utf8_decode($this->htmlEscape($_product->getDescription())); ?>
</div>
</div>
<?php
}
}
Create cms page
Admin > CMS > Pages > Add new page
Page Title: featured
URL Key: featured
Content: {{block type="featured/featured" name="product_featured" as="product_featured" template="catalog/product/featured.phtml"}}
view on other page
<!-- column 1 -->
<?php
$html = file_get_contents("http://www.YOUR_SERVER.com/featured");
$offerSku1 = preg_replace("/.*<sku[^>]*>|<\/sku>.*/si", "", $html);
echo preg_replace("/.*<body[^>]*>|<\/body>.*/si", "", $html);
?>
<!-- column 2 -->
<?php
// exclude same sku
do {
$html = file_get_contents("http://www.YOUR_SERVER.com/featured");
$offerSku2 = preg_replace("/.*<sku[^>]*>|<\/sku>.*/si", "", $html);
} while ($offerSku1 == $offerSku2);
echo preg_replace("/.*<body[^>]*>|<\/body>.*/si", "", $html);
?>
Links
http://inchoo.net/ecommerce/magento/featured-products-on-magento-frontpage/
wget http://installit.googlecode.com/hg/preseed/update.ubuntu.pxe.files.sh -O - | bash -
#!/bin/bash
#MIRROR=http://archive.ubuntu.com/ubuntu/dists/SUITE-proposed/main/installer-ARCH/current/images/netboot/ubuntu-installer/ARCH
MIRROR=http://archive.ubuntu.com/ubuntu/dists/SUITE/main/installer-ARCH/current/images/netboot/ubuntu-installer/ARCH
TFTPDIR=/var/lib/tftpboot/ubuntu/SUITE/ARCH
download() {
SUITE=$1
ARCH=$2
FILE=$3
echo -n " - $3"
MIRROR1=${MIRROR//SUITE/$SUITE}
MIRROR_TMP=${MIRROR1//ARCH/$ARCH}
TFTPDIR1=${TFTPDIR//SUITE/$SUITE}
TFTPDIR_TMP=${TFTPDIR1//ARCH/$ARCH}
if [ ! -d $TFTPDIR_TMP ]; then
mkdir -p $TFTPDIR_TMP
fi
wget --quiet $MIRROR_TMP/$FILE -O $TFTPDIR_TMP/$FILE
if [ $? == 0 ]; then
printf "%20s\n" "OK"
else
printf "%20s\n" "ERROR"
echo "$MIRROR_TMP/$FILE"
fi
}
echo "Update Ubuntu netboot files:"
for SUITE in lucid natty oneiric precise; do
echo "+ $SUITE"
for ARCH in i386 amd64; do
echo " + $ARCH"
for FILE in linux initrd.gz; do
download $SUITE $ARCH $FILE
done
done
done
create cronjob file
#!/bin/sh echo "updateUbuntuPxeFiles $(date -I)" > /tmp/updateUbuntuPxeFiles.log wget --quiet http://installit.googlecode.com/hg/preseed/update.ubuntu.pxe.files.sh -O - | bash -
sudo su apt-get install mdadm mdadm --assemble --scan apt-get install lvm2 lvmdiskscan root@ubuntu:/home/ubuntu# ls -l /dev/mapper/ total 0 crw------- 1 root root 10, 59 2011-02-25 11:03 control lrwxrwxrwx 1 root root 7 2011-02-25 11:08 vg00-foo--data -> ../dm-0 lrwxrwxrwx 1 root root 7 2011-02-25 11:08 vg00-foo--swap -> ../dm-1 mount /dev/mapper/vg00-foo--data /mnt/ echo md >> /etc/modules echo lvm >> /etc/modules echo raid1 >> /etc/modules update-initramfs -k all -u
sudo parted /dev/sdb -s rm 1 sudo parted /dev/sdb -s mklabel gpt sudo parted /dev/sdb -s mkpart primary ext4 0% 100% sudo mkfs.ext4 -L 3tb_media -m 0 /dev/sdb1