Load product by attribute in magento

While generally we load a product in Magento by its id, it is also possible to load product by attribute in magento. To do that use the following code –

$product = Mage::getModel('catalog/product')->loadByAttribute('attribute_name', $attribute_value);

Just replace ‘attribute_name’ with the name of the attribute and $attribute_valuewith the value and then Magento will return the matching products.

Update products stock by code magento

Sometimes when using EDI(Electronic data interchange) we need to update the product attributes in magento
For example EDI846 which deals with product stock
So how can we do this lets see
First of all we need to process the edi files and get the sku and qty from it
and rest of them is as shown below in the code snippet

$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
$productId = $product->getId();
$stockItem =Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
$stockItemId = $stockItem->getId();
$stockItem->setData('is_in_stock', 1);
$stockItem->setData('qty', (integer)$qty);
$stockItem->save();

So with not much effort we can update products stock by code in magento

Cron job command in cpanel

Here is the code snippet to add a cron job in cpanel ie cron job command in cpanel

/usr/bin/php -q /home/{user}/public_html/{docron.php}

here {user} has to be replaced with your username and
{docron.php} with the file you need to excecute

Hope this helps you to set a cron job

PHP Tour Lyon calling for papers

phptour-lyonThe PHP Tour Lyon 2014, organized by AFUP, French PHP Users Association, will be held on June 23st and 24th. The PHP Tour event is a conference moving each year all around the country. Nantes in 2012, Lille in 2011… Lyon is proud to welcome the next step of this PHP “Tour de France” !

Expert in PHP domains, or speakers taking part in an Open Source project, please come and share your experience!

Are you expert in some specific PHP domains? Did you deploy one or several PHP applications (CMS, e-commerce, CRM, EDMS) in a particular context (heavy load, famous customer, innovating project)? Are you taking part in an Open Source project? Come and share your experience!

The Forum is mainly constituted by conferences and workshops throughout the two days, possibly completed by other informal speeches. Conferences should last 45 minutes, followed by a QA session.

Proposals will be reviewed after the deadline has passed (February 28th). Additional information may be asked where needed. Proposals will be chosen according to their layout, relevancy for a professional audience and the overall homegeneity of the forum. Every candidate will be personnally notified of the status of their proposal. The decision is final.

Don’t forget : registration for the PHP Tour Lyon 2014 is already open, and Early Bird tickets are still available. Save 100€ for 2 days !

Read more at http://www.php.net/conferences/index.php#id2013-12-30-1