<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>
<meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no' name='viewport'/>
Mar 26, 2012
Mobile: Html meta data and headers
Sample Mobile Meta and headers
Magento: Hack - Nested addAttributeToFilter.
I already waste my one whole working day to look on this problem but still can file the solution. So I decide to modify the the magento core.
Here's the condition I want to do in addAttributeToFilter function.
To solve this Fucking problem I modify this class Mage_Eav_Model_Entity_Collection_Abstract.
Here my modify version.
In your product collection.
Happy Coding. :)
Here's the condition I want to do in addAttributeToFilter function.
(condition1) OR ((condition2) and (condition3) ..... )
To solve this Fucking problem I modify this class Mage_Eav_Model_Entity_Collection_Abstract.
public function addAttributeToFilter($attribute, $condition=null, $joinType='inner')
{
....Some Code here
if (is_array($attribute)) {
$sqlArr = array();
foreach ($attribute as $condition) {
$sqlArr[] = $this->_getAttributeConditionSql($condition['attribute'], $condition, $joinType);
}
$conditionSql = '('.join(') OR (', $sqlArr).')';
}else{
... your other code here.
}
Here my modify version.
public function addAttributeToFilter($attribute, $condition=null, $joinType='inner')
{
....Some Code here
if (is_array($attribute)) {
$sqlArr = array();
$myAND = array();
$andSqlArr = array();
/*
* @ win mode to support (x=a) or (y=1 and z=0)
* array(
* array(condition)
* 'and' =>
* array(
* array(condition)
* array(condition)
* ),
* )
*
* Output expected
* cond1 OR (cond2 and cond3)
*/
foreach ($attribute as $key => $condition) {
if ($key === "and"){
$myAND = $condition;
continue;
}
$sqlArr[] = $this->_getAttributeConditionSql($condition['attribute'], $condition, $joinType);
}
foreach ($myAND as $key => $andCond ){
$andSqlArr[] = $this->_getAttributeConditionSql(
$andCond['attribute'],
$andCond,
$joinType);
}
$conditionSql = '('.join(') AND (', $andSqlArr).')';
if ($andSqlArr){
$sqlArr[] = $conditionSql;
}
$conditionSql = '('.join(') OR (', $sqlArr).')';
}
... your other code here.
}
In your product collection.
$collection->addFieldToFilter(
array(
array("attribute"=>"your_attribute1", "in"=>array(1,2,3,)),
"and" => array(
array("attribute"=>"your_attribute2", "eq"=>1,),
array("attribute"=>"your_attribute3", "eq"=>1,),
),
)
);
Happy Coding. :)
Mar 22, 2012
SVN: SSL handshake failed: Secure connection truncated
I experience this error in my fedora 14 with svn version
Here my command
Response
From Jan's Blog instructed to install libneon27 However before in install I check /usr/lib/libneon.so.27 and exist to my filesystem so I just issue.
Cheers.. :)
svn --version
svn, version 1.6.17 (r1128011)
compiled Jun 2 2011, 15:23:50
Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository access (RA) modules are available:
* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
Here my command
$ svn export https://mycode.googlecode.com/svn/trunk/ mycode --username admin@syntax3rror.co.cc
Response
svn: OPTIONS of 'https://mycode.googlecode.com/svn/trunk': SSL handshake failed: Secure connection truncated (https://mycode.googlecode.com)
From Jan's Blog instructed to install libneon27 However before in install I check /usr/lib/libneon.so.27 and exist to my filesystem so I just issue.
sudo ln -s /usr/lib/libneon.so.27 /usr/lib/libneon-gnutls.so.27
Cheers.. :)
Magento: Deleting Product
A simple way to delete product is:
$productId = 1;
Mage::getSingleton('catalog/product')
->load($productId)
->delete();
If you want to delete product by category
$collection = Mage::getSingleton('catalog/category')
->load(YOUR_CATEGORY_ID)
->getproductCollection();
// If you want to filter by attribute
$collection->addAttributeToFilter('YOUR_ATTRIBUTE_CODE', 'ATTRIBUTE_VALUE')
foreach($collection as $product){
$product =Mage::getSingleton('catalog/product')
->load($product->getId())
try {
// Im not sure what is the use of this part
Mage::dispatchEvent(
'catalog_controller_product_delete',
array('product' => $product));
// Finally we not able to delete the product
$product->delete();
}catch (Exception $e) {
echo "Can't delete product w/ id: $product";
}
}
Reference:
Delete magento Product
Subscribe to:
Posts (Atom)