Note that there are some explanatory texts on larger screens.

plurals
  1. POOR and AND STATEMENT addAttributeToFilter magento
    primarykey
    data
    text
    <p>I have created the following code.</p> <pre><code>$todayDate = Mage::app()-&gt;getLocale()-&gt;date()-&gt;toString(Varien_Date::DATETIME_INTERNAL_FORMAT); $tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y')); $dateTomorrow = date('m/d/y', $tomorrow); $collection = Mage::getResourceModel('catalog/product_collection'); $collection-&gt;setVisibility(Mage::getSingleton('catalog/product_visibility')-&gt;getVisibleInCatalogIds()); $collection = $this-&gt;_addProductAttributesAndPrices($collection) -&gt;addStoreFilter() -&gt;addAttributeToFilter('special_price', array('neq' =&gt; "")) -&gt;addAttributeToFilter('special_from_date', array('date' =&gt; true, 'to' =&gt; $todayDate)) -&gt;addAttributeToFilter('special_to_date', array('or'=&gt; array(0 =&gt; array('date' =&gt; true, 'from' =&gt; $dateTomorrow), 1 =&gt; array('is' =&gt; new Zend_Db_Expr('null')))), 'left'); </code></pre> <p>This is working fine. But what i want is to use the OR statement right now. I thought i could fix it with this:</p> <pre><code>$collection-&gt;addAttributeToFilter(array( array('attribute'=&gt; 'someattribute','like' =&gt; 'value'), array('attribute'=&gt; 'otherattribute','like' =&gt; 'value'), array('attribute'=&gt; 'anotherattribute','like' =&gt; 'value'), )); </code></pre> <p>But no succes. So my question is how to add OR statement to this.</p> <pre><code>$todayDate = Mage::app()-&gt;getLocale()-&gt;date()-&gt;toString(Varien_Date::DATETIME_INTERNAL_FORMAT); $tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y')); $dateTomorrow = date('m/d/y', $tomorrow); $collection = Mage::getResourceModel('catalog/product_collection'); $collection-&gt;setVisibility(Mage::getSingleton('catalog/product_visibility')-&gt;getVisibleInCatalogIds()); $collection = $this-&gt;_addProductAttributesAndPrices($collection) -&gt;addStoreFilter() -&gt;addAttributeToFilter('special_price', array('neq' =&gt; "")) -&gt;addAttributeToFilter('special_from_date', array('date' =&gt; true, 'to' =&gt; $todayDate)) -&gt;addAttributeToFilter('special_to_date', array('or'=&gt; array(0 =&gt; array('date' =&gt; true, 'from' =&gt; $dateTomorrow), 1 =&gt; array('is' =&gt; new Zend_Db_Expr('null')))), 'left'); </code></pre> <p>OR</p> <p>Thank you.</p> <p>Great, Lex</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload