Skip to content

Instantly share code, notes, and snippets.

@AndresInSpace
AndresInSpace / fixGetCrossSellProductCollection
Last active September 26, 2017 14:09
Fix getCrossSellProductCollection() to stop returning ENTIRE product catalog collection in object data..
<?php $plcsCol = Mage::getModel('catalog/product_link')->getCollection()->addFieldToFilter('link_type_id',Mage_Catalog_Model_Product_Link::LINK_TYPE_CROSSSELL)->addFieldToFilter('product_id',$_product->getId())->getData();//get crosssell product IDs attached to parent product ?>
<?php $csIDs = array_column($plcsCol,'linked_product_id');//map cs IDs to array, use array to filter collection by IDs ?>
<?php $_crossSellProducts = $_product->getCrossSellProductCollection()->addAttributeToFilter('entity_id', array('in'=>$csIDs))->addAttributeToSelect('*'); //ensures our crosssell collection is limited to ONLY attached crossells of parent.. calling getCrossSellProductCollection without filtering seems to return the ENTIRE product catalog collection..
//replace addAttributeToSelect('*') with whatever fields you need from product flat catalog..
@AndresInSpace
AndresInSpace / jquery.waituntilexists.js
Created December 18, 2016 01:06 — forked from PizzaBrandon/jquery.waituntilexists.js
Updated waitUntilExists plugin
;(function ($, window) {
var intervals = {};
var removeListener = function(selector) {
if (intervals[selector]) {
window.clearInterval(intervals[selector]);
intervals[selector] = null;
}