Skip to content

Instantly share code, notes, and snippets.

View justindocanto's full-sized avatar

Justin DoCanto justindocanto

  • The Lender Marketing Group
  • California
View GitHub Profile
@justindocanto
justindocanto / instagram.php
Last active June 12, 2016 06:01
Get last 12 Instagram photos in PHP using /username/media/ json feed
<div class="row">
<?php
function fetchData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
@justindocanto
justindocanto / functions.php
Last active October 15, 2015 03:21
Disable XML-RPC in WordPress
// Disable XML-RPC
add_filter('xmlrpc_enabled', '__return_false');
@justindocanto
justindocanto / gist:9ce1ece82deb64b1b3d5
Created June 1, 2015 21:56
Magento - get all the products in a category
<?php
// Get products from within a category
function getCatProds($catid) {
$baseURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
$category = new Mage_Catalog_Model_Category();
$category->load($catid); // this is your category id
$collection = $category->getProductCollection();
foreach($collection as $product) {
$id[] = $product->getId();
}
@justindocanto
justindocanto / gist:35cd134a15246e1f40ac
Created June 1, 2015 21:55
Magento - Return id, name & url of product categories
<?php
// Get Magento categories
function get_magento_categories() {
require_once 'app/Mage.php';
Mage::app();
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
$categories = array();
@justindocanto
justindocanto / gist:42423d28b735a407b812
Last active August 29, 2015 14:22
Use WordPress functions within Magento
<?php
// I do a lot of websites where the client would like the ease of WordPress for a blog and
// for regular pages, but want something enterprise level for the e-commerce portion of
// their site. In order to service this need, I usually setup a wordpress site as the main
// site and then setup Magento as a secondary site at something like example.com/shop/.
// Then, I use the following 'hack' in order to use WP elements from within Magento so I
// don't have to do twice the work and/or so the client, if they are managing the site
// themselves, don't have to change things in two places. For example, you can use WordPress
// nav menus within Magento, so that you don't have to maintain 2 menus. You can also call