Skip to content

Instantly share code, notes, and snippets.

<?php
$curl = curl_init('place url');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$page = curl_exec($curl);
if(curl_errno($curl)) // check for execution errors
{
echo 'Scraper error: ' . curl_error($curl);
exit;
<?php
$parentCategoryId = 107;
$cat = Mage::getModel('catalog/category')->load($parentCategoryId);
$subcats = $cat->getChildren();
?>
// Get 1 Level sub category of Parent category.
<?php
@Vernonmac
Vernonmac / magento-get-manufacturers-list-from-current-category.php
Created April 6, 2015 09:11
Magento, display manufacturers list from current category
<?php
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
?>
@Vernonmac
Vernonmac / magento-random-products-from-category.php
Last active August 29, 2015 14:18
Display products from the same category on the product page in Magento | /app/design/frontend/YOUR_TEMPLATE/template/catalog/product/view.phtml
<?php
if ($_product) {
// get collection of categories this product is associated with
$categories =$_product->getCategoryCollection()
->setPage(1, 1)
//->addFieldToFilter(‘level’,"3")
//->addFieldToFilter(‘parent_id’,"3")
//->setOrder("level")
->load();
$orderaddress = Mage::getModel('sales/order_address')->load($order->getShippingAddressId());
$street_first_line = $orderaddress->getStreet(1);
return $street_first_line;
$orderaddress = Mage::getModel('sales/order_address')->load($order->getShippingAddressId());
$street_second_line = $orderaddress->getStreet(2);
return $street_second_line;
@Vernonmac
Vernonmac / magento-remove-dashboard-links.phtml
Created June 22, 2014 12:23
Magento Remove Dashboard Links
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<!-- ## Default Layout ## -->
<default>
<!-- Remove unwanted blocks entirely
<remove name="right.poll"/>
<remove name="right.permanent.callout"/>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('staticblock_identifier')->toHtml() ?>
jQuery.fn.verticalAlign = function ()
{
return this
.css("margin-top",($(this).parent().height() - $(this).height())/2 + 'px' )
};
$('element').verticalAlign();
$(window).bind('resize', function(e){
window.resizeEvt;
$(window).resize(function(){
clearTimeout(window.resizeEvt);
window.resizeEvt = setTimeout(function(){
} ,500);
});
});