Wednesday, January 13, 2016

Delete Product Attribute Programatically

<?phpdefine('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
Mage::app();

echo "Begining...."."\n";
try{
$model = new Mage_Eav_Model_Entity_Setup('core_setup');
// your attribute code here
$attribute_id = 'salelabel'
// Remove Product Attribute
$model->removeAttribute('catalog_product', $attribute_id);
echo "Done"."\n";
}catch(Exception $e)
{
  echo "An exception occured.".$e->getMessage();      
}
echo "Ending...."."\n";

Download File Remotely

<?php /* Download a file remotely */$target_file = "/home/ism-apac/Desktop/Test/test.jpg";
$url = "https://nthm3.s3.amazonaws.com/catalog/o/48631a.jpg";

try{
file_put_contents($target_file, fopen($url, 'r'));
}
catch(Exception $e)
{
  echo $e->getMessage();
}
?>

Re-index Magento via SSH

How to do:
1. Login to Server using SSH
> pwd
> ls -al

2. Move to ROOT/shell folder
> cd shell/
> ls -al

3. Get help from “indexer.php” script
> php -f indexer.php help

4. Get the list of indexers which you can execute
> php -f indexer.php info

Ex:
catalog_product_attribute     Product Attributes
catalog_product_price         Product Prices
//===============================================
catalog_url                   Catalog Url Rewrites
//===============================================
catalog_product_flat          Product Flat Data
catalog_category_flat         Category Flat Data
catalog_category_product      Category Products
catalogsearch_fulltext        Catalog Search Index
cataloginventory_stock        Stock status

cataloginventory_stock        Stock Status
catalog_product_price         Catalog product price
catalog_url_category          Category URL Rewrites
catalog_url_product           Product URL Rewrites
//===============================================
url_redirect                  URL Redirects
//===============================================
catalog_category_product      Catalog Category/Product Index
catalogsearch_fulltext        Catalog Search Index
tag_summary                   Tag Aggregation Data
catalog_product_attribute     Product Attributes


5. you can reindex any of the indexers one by one.
> php indexer.php --reindex   <<reindexer_name>>
Ex:
> php indexer.php --reindex catalog_url_category

6. If you want to reindex everything at once, use the below command
> php indexer.php -reindexall

Run Magento Cron programatically

<?php
define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
Mage::app();

echo "Begining...."."\n";
try{
$observer = Mage::getModel("ism_import/cron_stock");
$vall = $observer->importStock();
print_r($vall);
}catch(Exception $e)
{
  echo "An exception occured.".$e->getMessage();      
}
echo "Ending...."."\n";

Install Script to add Product "Drop down" attribute

<?php
/* @var $model Mage_Eav_Model_Entity_Setup */$model = Mage::getModel('eav/entity_setup','core_setup');

$model->startSetup();

$data = array(
    'type'              =>  'varchar',
    'input'             =>  'select',
    'label'             =>  'Sale Label',
    'global'            =>  Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
    'required'          =>  '0',
    'comparable'        =>  '0',
    'searchable'        =>  '0',
    'is_unique'         =>  '1',
    'is_configurable'   =>  '1',
    'user_defined'      =>  true,
    'group'             =>  'Kixx online',
    'attribute_set'     =>  'Producten');

$model->addAttribute('catalog_product', 'salelabel', $data);


$attributeId        =   $model->getAttribute('catalog_product','salelabel');
$attributeSetId     =   $model->getAttributeSetId('catalog_product','Producten');
/** Get attribute group info */$attributeGroupId   =   $model->getAttributeGroup('catalog_product',$attributeSetId,'Kixx online');
/** Add attribute to a set */$model->addAttributeToSet('catalog_product',$attributeSetId,$attributeGroupId,$attributeId);

$model->endSetup();

Set Base Image on Thumbnail Image

<?php
require_once '../app/Mage.php';

Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('admin');

Mage::register('isSecureArea', 1);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

set_time_limit(0);
ini_set('memory_limit','1024M');

$connection = Mage::getSingleton('core/resource')->getConnection('core_write');

$sqlSp = "select entity_id from catalog_product_entity_varchar where `value` like '%https:%' and attribute_id = 87";
$res = $connection->fetchAll($sqlSp);

foreach ($res as $v) {
    $entityID = $v["entity_id"];
    $sqlURL = "select `value` from catalog_product_entity_varchar where entity_id = ? and attribute_id = 86";
    $url = $connection->fetchOne($sqlURL, $entityID);
    echo $entityID . " - " . $url . PHP_EOL;
    $sqlUpdte = "UPDATE catalog_product_entity_varchar SET `value` = ? where entity_id = ? and attribute_id = 87";
    $connection->query($sqlUpdte, array($url, $entityID));
}

Thursday, September 3, 2015

Privacy Policy: SNA with Linkedin, R and RStudio

Privacy Policy for the Linkedin Application : SNA with Linkedin, R and RStudio

Privacy Policy

Last Updated: August 30, 2015


This Privacy Policy describes Linkedin app named "SNA with Linkedin, R and RStudio" with  practices regarding the collection, use and disclosure of the information we collect from and about you when you use application. We take our obligations regarding your privacy seriously and have made every effort to draft this Privacy Policy in a manner that is clear and easy for you to understand. By accessing or using the Service, you agree to this Privacy Policy, our Terms of Service, and our Acceptable Use Policy.

Information You Provide to Us:

We collect personal information, such as your name and email address, when you are using "SNA with Linkedin, R and RStudio" app. You may also provide us with optional information such as a photograph. Your user name, email address and any optional profile information that you elect to associate with your account is referred to herein as your “Profile Information.”

"SNA with Linkedin, R and RStudio" app is used for educational purpose on Social Network Analysis with R language. This app is related to the research work conducted under Masters' Research program at University of Colombo School of Computing (UCSC), Sri Lanka. There is No intention, directly or indirectly, in sharing the data gathered through this app to a third party and the whole desire is using the gathered information for educational purpose only.

We may not use your email address to send you Service-related notices (including any notices required by law, in lieu of communication by postal mail).You may not receiving Marketing Messages at any time.

Sharing Your Information

At any instance, we may Not share your information intentionally nor unintentionally with a third party. The whole idea of gathering data is for academic purpose and on concept proofing.

How We Protect Your Information

The security of your information is important to us. Hence None of the personal information will be disclosed to a third party.

If you have any questions about security on our Service,contact us at oshancp@yahoo.com

Your Choices About Your Information

You may, of course, decline to submit personally identifiable information through the app. You may update or correct your account information at any time by logging in to your account.

Changes to Our Privacy Policy

If we change our Privacy Policy, we will post those changes on this page to keep you aware of what information we collect, how we use it and under what circumstances we may disclose it. Changes to this Privacy Policy are effective when they are posted on this page.

Contact Us

For questions about these or any terms or policies, email us at oshancp@yahoo.com