Sep 26, 2011

Java Heap Parameters


-Xmx2048m
-Xloggc:gc.log
-XX:-PrintGCDetails
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./dump.hprof
-XX:+UseConcMarkSweepGC

Sep 21, 2011

Magento: How to check if has access to page?

Syntax:



Mage::getSingleton('admin/session')
->isAllowed('[resource_item1_path]/[resource_item1_child_path]')

Example:



$adminSession = Mage::getSingleton('admin/session');
// Checks the permission for managing of products
$adminSession->isAllowed('admin/catalog/products');

// Checks the permission for the order creation in Magento Admin
$adminSession->isAllowed('sales/order/create');

// Checks the permission for the order view in Magento Admin
$adminSession->isAllowed('sales/order/view'));


Reference:
Defining acl resources custom and admin menu

Sep 19, 2011

Magento: Get parent product for configurable product.


$_product = Mage::getModel('catalog/product')->load(YOUR_SIMPLE_PRODUCT_ID);
$parentIdArray = $_product->loadParentProductIds()->getData('parent_product_ids');
print_r($parentIdArray);

Get associated configurable product



/**
* Load product by product id
*/
$product = Mage::getModel('catalog/product')->(YOUR_PRODUCT_ID);

/**
* Get child products id (only ids)
$childIds = Mage::getModel('catalog/product_type_configurable')
->getChildrenIds($product->getId());

/**
* Get children products (all associated children products data)
*/
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);

Reference:
magento-how-to-get-all-associated-children-product-of-a-configurable-product
magento-get-parent-id-of-simple-product-associated-to-configurable-product

Linux; VI reference

Reference:
Nice One
VimReferenceCard.pdf

Sep 18, 2011

Mageno: Create Empty Template.

In your controller action issued this command.

$this->loadLayout(false); // Issue this to disable loading of your layout
$this->getResponse()->setHeader('Content-Type','text/xml'); // Set this depending on you file content type

/**
* .... Put you other code here
*/
$this->renderLayout(); // Finally render your layout


For complete details see also the source Custom controller actions result in blank template

Linux: How to create Public key using private key


$ ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub

Linux: Find file by size


find -type f -size +200 -exec gzip -q{}\;
or
find PATH -type f -size +100000k -exec ls -lh {} \; | awk ‘{ print $9 “: ” $5 }’


Reference:
Find files larger than size x
a-bash-script-to-find-large-files-on-a-linux-server

Sep 14, 2011

Symfony: Propel Custom Join

NOTE:
In Didn't try this yet. May I update this page after I test in my self too. Thsi will serve a reference for the mentime.

References
ApplyingCustomJoinsInDoSelect

Symfony: Propel Custom Query

Here's sample Code

$connection = Propel::getConnection();
$query = 'SELECT MAX(?) AS max FROM ?';
$statement = $connection->prepareStatement($query);
$statement->setString(1, ArticlePeer::CREATED_AT);
$statement->setString(2, ArticlePeer::TABLE_NAME);
$resultset = $statement->executeQuery();
$resultset->next();
$max = $resultset->getInt('max')


Reference
08-Inside-the-Model-Layer

Magento models.

AttributeSet
Mage::getModel("eav/entity_attribute_set");
Product
Mage::getModel("catalog/product");


Rerefence:
how-do-i-get-attribute-set-name