-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' for 1.2.0 release
- Loading branch information
Showing
24 changed files
with
1,819 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,53 @@ | ||
# magento-LCB_Attachments | ||
# LCB_Attachments | ||
Magento attachments plugin with attachment type and multistore support | ||
|
||
|
||
## Version | ||
|
||
###1.2.0 | ||
|
||
## Changelog | ||
|
||
### 1.1.0 | ||
|
||
* Added modman | ||
* Fixed minor bugs, added new features | ||
|
||
### 1.1.1 | ||
|
||
* Added download logic for attachments and images | ||
|
||
### 1.1.2 | ||
|
||
* Added optional type of content display for categories | ||
|
||
### 1.1.3 | ||
|
||
* Added support for attachments thumbnails/icons and Imagick support for pdf covers | ||
|
||
### 1.1.4 | ||
|
||
* Fixed image logic, option for both attachments and images download | ||
|
||
### 1.1.5 | ||
|
||
* Minor amends for downloads, pdf cover and Imagick exception support | ||
|
||
### 1.1.6 | ||
|
||
* Added movies support and attachment image resize feature | ||
|
||
### 1.1.7 | ||
|
||
* Added support for youtube downloads (based on Stephan Schmitz yt_downloader) and CSRF protection | ||
|
||
### 1.1.8 | ||
|
||
* Added support for direct movie url render and download | ||
|
||
### 1.1.9 | ||
|
||
* Added store filter for attachments category methods | ||
|
||
### 1.2.0 | ||
|
||
* Store filter fixes for product tab. Version bump for 1.2.0 release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
|
||
/** | ||
* Attachments | ||
* | ||
* @category LCB | ||
* @package LCB_Attachments | ||
* @author Silpion Tomasz Gregorczyk <[email protected]> | ||
*/ | ||
class LCB_Attachments_Block_Index extends Mage_Core_Block_Template { | ||
|
||
/** | ||
* Get media images from products | ||
* | ||
* @return Varien_Data_Collection | ||
*/ | ||
public function getProductImages() | ||
{ | ||
$collection = new Varien_Data_Collection(); | ||
|
||
$categoryId = $this->getRequest()->getParam('category'); | ||
$subcategoryId = $this->getRequest()->getParam('subcategory'); | ||
$productId = $this->getRequest()->getParam('product'); | ||
$photoIds = $this->getRequest()->getParam('photos'); | ||
|
||
$products = Mage::getModel('catalog/product')->getCollection() | ||
->addAttributeToSelect('small_image') | ||
->addAttributeToSelect('thumbnail') | ||
->addAttributeToSelect('image'); | ||
$products->addAttributeToFilter('small_image', array('neq' => "no_selection")); | ||
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products); | ||
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products); | ||
|
||
if (!empty($categoryId) && empty($subcategoryId)) { | ||
$category = Mage::getModel('catalog/category')->load($this->getRequest()->getParam('category')); | ||
$products->addCategoryFilter($category); | ||
} | ||
|
||
if (!empty($subcategoryId)) { | ||
$category = Mage::getModel('catalog/category')->load($this->getRequest()->getParam('subcategory')); | ||
$products->addCategoryFilter($category); | ||
} | ||
|
||
if (!empty($productId)) { | ||
$products->addAttributeToFilter('entity_id', array('in' => array($this->getRequest()->getParam('product')))); | ||
} | ||
|
||
if (empty($photoIds)) { | ||
$products->getSelect()->order('RAND()'); | ||
$products->getSelect()->limit(16); | ||
} | ||
|
||
foreach ($products as $_product) { | ||
$product = Mage::getModel('catalog/product')->load($_product->getId()); | ||
foreach ($product->getMediaGalleryImages() as $image) { | ||
|
||
if (!empty($photoIds)) { | ||
if (!in_array($image->getId(), $photoIds)) { | ||
continue; | ||
} | ||
} | ||
|
||
if (!$image->getLabel()) { | ||
$image->setLabel($product->getName()); | ||
} | ||
|
||
$mime = pathinfo($image->getPath(), PATHINFO_EXTENSION); | ||
$image->setMime($mime); | ||
|
||
$filesize = filesize($image->getPath()) * .0009765625; // bytes to KB | ||
$image->setSize(round($filesize)); | ||
|
||
$collection->addItem($image); | ||
} | ||
} | ||
|
||
return $collection; | ||
} | ||
|
||
/** | ||
* Get categories to populate first select | ||
* | ||
* @return Mage_Catalog_Model_Resource_Category_Collection $categories | ||
*/ | ||
public function getCategories() | ||
{ | ||
$categories = Mage::getModel('catalog/category')->getCollection() | ||
->addAttributeToSelect('*') | ||
->addAttributeToFilter('level', 2) | ||
->addAttributeToFilter('is_active', 1); | ||
return $categories; | ||
} | ||
|
||
/** | ||
* Get subcategories to populate second select | ||
* | ||
* @return mixed array|Mage_Catalog_Model_Resource_Category_Collection $categories | ||
*/ | ||
public function getSubcategories() | ||
{ | ||
if (!$this->getRequest()->getParam('category')) { | ||
return array(); | ||
} | ||
|
||
$categories = Mage::getModel('catalog/category')->getCollection() | ||
->addAttributeToSelect('*') | ||
->addAttributeToFilter('level', 3) | ||
->addAttributeToFilter('parent_id', $this->getRequest()->getParam('category')) | ||
->addAttributeToFilter('is_active', 1); | ||
return $categories; | ||
} | ||
|
||
/** | ||
* Get subcategories to populate second select | ||
* | ||
* @return mixed array|Mage_Catalog_Model_Resource_Product_Collection $products | ||
*/ | ||
public function getProducts() | ||
{ | ||
if (!$this->getRequest()->getParam('subcategory')) { | ||
return array(); | ||
} | ||
|
||
$products = Mage::getModel('catalog/category')->load($this->getRequest()->getParam('subcategory')) | ||
->getProductCollection() | ||
->addAttributeToSelect('*'); | ||
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products); | ||
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products); | ||
$products->getSelect()->limit(240); | ||
return $products; | ||
} | ||
|
||
/** | ||
* Get attachments within specific category id | ||
* | ||
* @param int $categoryId | ||
* @return LCB_Attachments_Model_Resource_Attachment_Collection $attachments | ||
*/ | ||
public function getAttachments($categoryId, $store = false) | ||
{ | ||
$attachments = Mage::getModel('lcb_attachments/category')->load($categoryId)->getAttachments(); | ||
if ($store) { | ||
$attachments->addStoreFilter($store); | ||
} | ||
return $attachments; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.