Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mage_CatalogInventory - DOC block update #780

Merged
merged 4 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function _getCustomerGroups($groupId = null)
$this->_customerGroups = array();
$collection = Mage::getModel('customer/group')->getCollection();
foreach ($collection as $item) {
/* @var $item Mage_Customer_Model_Group */
/* @var Mage_Customer_Model_Group $item */
$this->_customerGroups[$item->getId()] = $item->getCustomerGroupCode();
}
}
Expand All @@ -70,6 +70,10 @@ protected function _getCustomerGroups($groupId = null)
return $this->_customerGroups;
}

/**
* @param string $value
* @return Mage_CatalogInventory_Block_Adminhtml_Form_Field_Customergroup
*/
public function setInputName($value)
{
return $this->setName($value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ protected function _getGroupRenderer()
{
if (!$this->_groupRenderer) {
$this->_groupRenderer = $this->getLayout()->createBlock(
'cataloginventory/adminhtml_form_field_customergroup', '',
'cataloginventory/adminhtml_form_field_customergroup',
'',
array('is_render_to_js_template' => true)
);
$this->_groupRenderer->setClass('customer_group_select');
Expand Down Expand Up @@ -76,7 +77,7 @@ protected function _prepareToRender()
/**
* Prepare existing row data object
*
* @param Varien_Object
* @param Varien_Object $row
*/
protected function _prepareArrayRow(Varien_Object $row)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,4 @@ public function isMsgVisible()
{
return ($this->getStockQty() > 0 && $this->getStockQty() <= $this->getThresholdQty());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function getChildProducts()
/**
* Retrieve product stock qty
*
* @param Mage_Catalog_Model_Product $product
* @return float
*/
public function getProductStockQty($product)
Expand Down
12 changes: 6 additions & 6 deletions app/code/core/Mage/CatalogInventory/Helper/Minsaleqty.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function _serializeValue($value)
if (is_numeric($value)) {
$data = (float)$value;
return (string)$data;
} else if (is_array($value)) {
} elseif (is_array($value)) {
$data = array();
foreach ($value as $groupId => $qty) {
if (!array_key_exists($groupId, $data)) {
Expand Down Expand Up @@ -79,7 +79,7 @@ protected function _unserializeValue($value)
return array(
Mage_Customer_Model_Group::CUST_GROUP_ALL => $this->_fixQty($value)
);
} else if (is_string($value) && !empty($value)) {
} elseif (is_string($value) && !empty($value)) {
try {
return Mage::helper('core/unserializeArray')->unserialize($value);
} catch (Exception $e) {
Expand All @@ -93,7 +93,7 @@ protected function _unserializeValue($value)
/**
* Check whether value is in form retrieved by _encodeArrayFieldValue()
*
* @param mixed
* @param mixed $value
* @return bool
*/
protected function _isEncodedArrayFieldValue($value)
Expand All @@ -113,7 +113,7 @@ protected function _isEncodedArrayFieldValue($value)
/**
* Encode value to be used in Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
*
* @param array
* @param array $value
* @return array
*/
protected function _encodeArrayFieldValue(array $value)
Expand All @@ -132,7 +132,7 @@ protected function _encodeArrayFieldValue(array $value)
/**
* Decode value from used in Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
*
* @param array
* @param array $value
* @return array
*/
protected function _decodeArrayFieldValue(array $value)
Expand Down Expand Up @@ -169,7 +169,7 @@ public function getConfigValue($customerGroupId, $store = null)
if ($groupId == $customerGroupId) {
$result = $qty;
break;
} else if ($groupId == Mage_Customer_Model_Group::CUST_GROUP_ALL) {
} elseif ($groupId == Mage_Customer_Model_Group::CUST_GROUP_ALL) {
$result = $qty;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Mage_CatalogInventory_Model_Api2_Stock_Item extends Mage_Api2_Model_Resour
*/
protected function _loadStockItemById($id)
{
/* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
/* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
$stockItem = Mage::getModel('cataloginventory/stock_item')->load($id);
if (!$stockItem->getId()) {
$this->_critical(self::RESOURCE_NOT_FOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
* @package Mage_CatalogInventory
* @author Magento Core Team <core@magentocommerce.com>
*/
abstract class Mage_CatalogInventory_Model_Api2_Stock_Item_Rest
extends Mage_CatalogInventory_Model_Api2_Stock_Item
abstract class Mage_CatalogInventory_Model_Api2_Stock_Item_Rest extends Mage_CatalogInventory_Model_Api2_Stock_Item
{
/**
* Retrieve information about specified stock item
Expand All @@ -42,7 +41,7 @@ abstract class Mage_CatalogInventory_Model_Api2_Stock_Item_Rest
*/
protected function _retrieve()
{
/* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
/* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
$stockItem = $this->_loadStockItemById($this->getRequest()->getParam('id'));
return $stockItem->getData();
}
Expand All @@ -65,7 +64,7 @@ protected function _retrieveCollection()
*/
protected function _getCollectionForRetrieve()
{
/* @var $collection Mage_CatalogInventory_Model_Resource_Stock_Item_Collection */
/* @var Mage_CatalogInventory_Model_Resource_Stock_Item_Collection $collection */
$collection = Mage::getResourceModel('cataloginventory/stock_item_collection');
$this->_applyCollectionModifiers($collection);
return $collection;
Expand All @@ -79,10 +78,10 @@ protected function _getCollectionForRetrieve()
*/
protected function _update(array $data)
{
/* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
/* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
$stockItem = $this->_loadStockItemById($this->getRequest()->getParam('id'));

/* @var $validator Mage_CatalogInventory_Model_Api2_Stock_Item_Validator_Item */
/* @var Mage_CatalogInventory_Model_Api2_Stock_Item_Validator_Item $validator */
$validator = Mage::getModel('cataloginventory/api2_stock_item_validator_item', array(
'resource' => $this
));
Expand Down Expand Up @@ -118,7 +117,7 @@ protected function _multiUpdate(array $data)
$this->_critical(self::RESOURCE_DATA_PRE_VALIDATION_ERROR);
}

/* @var $validator Mage_CatalogInventory_Model_Api2_Stock_Item_Validator_Item */
/* @var Mage_CatalogInventory_Model_Api2_Stock_Item_Validator_Item $validator */
$validator = Mage::getModel('cataloginventory/api2_stock_item_validator_item', array(
'resource' => $this
));
Expand All @@ -132,7 +131,7 @@ protected function _multiUpdate(array $data)
}

// Existence of a item is checked in the validator
/* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
/* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
$stockItem = $this->_loadStockItemById($itemData['item_id']);

unset($itemData['item_id']); // item_id is not for update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function isValidSingleItemDataForMultiUpdate(array $data)
$this->_addError('Invalid value for "item_id" in request.');
} else {
// Validate Stock Item
/* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
/* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
$stockItem = Mage::getModel('cataloginventory/stock_item')->load($data['item_id']);
if (!$stockItem->getId()) {
$this->_addError(sprintf('StockItem #%d not found.', $data['item_id']));
Expand Down
21 changes: 12 additions & 9 deletions app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function _construct()
/**
* Retrieve resource instance wrapper
*
* @return Mage_CatalogInventory_Model_Mysql4_Indexer_Stock
* @inheritDoc
*/
protected function _getResource()
{
Expand Down Expand Up @@ -142,22 +142,22 @@ public function matchEvent(Mage_Index_Model_Event $event)

$entity = $event->getEntity();
if ($entity == Mage_Core_Model_Store::ENTITY) {
/* @var $store Mage_Core_Model_Store */
/* @var Mage_Core_Model_Store $store */
$store = $event->getDataObject();
if ($store && $store->isObjectNew()) {
$result = true;
} else {
$result = false;
}
} else if ($entity == Mage_Core_Model_Store_Group::ENTITY) {
/* @var $storeGroup Mage_Core_Model_Store_Group */
} elseif ($entity == Mage_Core_Model_Store_Group::ENTITY) {
/* @var Mage_Core_Model_Store_Group $storeGroup */
$storeGroup = $event->getDataObject();
if ($storeGroup && $storeGroup->dataHasChangedFor('website_id')) {
$result = true;
} else {
$result = false;
}
} else if ($entity == Mage_Core_Model_Config_Data::ENTITY) {
} elseif ($entity == Mage_Core_Model_Config_Data::ENTITY) {
$configData = $event->getDataObject();
if ($configData && in_array($configData->getPath(), $this->_relatedConfigSettings)) {
$result = $configData->isValueChanged();
Expand Down Expand Up @@ -223,6 +223,7 @@ protected function _registerCatalogProductEvent(Mage_Index_Model_Event $event)
{
switch ($event->getType()) {
case Mage_Index_Model_Event::TYPE_SAVE:
/** @var Mage_Catalog_Model_Product $product */
$product = $event->getDataObject();
if ($product && $product->getStockData()) {
$product->setForceReindexRequired(true);
Expand Down Expand Up @@ -260,7 +261,7 @@ protected function _registerCatalogInventoryStockItemEvent(Mage_Index_Model_Even
*/
protected function _registerStockItemSaveEvent(Mage_Index_Model_Event $event)
{
/* @var $object Mage_CatalogInventory_Model_Stock_Item */
/* @var Mage_CatalogInventory_Model_Stock_Item $object */
$object = $event->getDataObject();

$event->addNewData('reindex_stock', 1);
Expand All @@ -273,7 +274,9 @@ protected function _registerStockItemSaveEvent(Mage_Index_Model_Event $event)
$massObject->setAttributesData(array('force_reindex_required' => 1));
$massObject->setProductIds(array($object->getProductId()));
Mage::getSingleton('index/indexer')->logEvent(
$massObject, Mage_Catalog_Model_Product::ENTITY, Mage_Index_Model_Event::TYPE_MASS_ACTION
$massObject,
Mage_Catalog_Model_Product::ENTITY,
Mage_Index_Model_Event::TYPE_MASS_ACTION
);
}

Expand All @@ -288,7 +291,7 @@ protected function _registerStockItemSaveEvent(Mage_Index_Model_Event $event)
*/
protected function _registerCatalogProductDeleteEvent(Mage_Index_Model_Event $event)
{
/* @var $product Mage_Catalog_Model_Product */
/* @var Mage_Catalog_Model_Product $product */
$product = $event->getDataObject();

$parentIds = $this->_getResource()->getProductParentsByChild($product->getId());
Expand All @@ -307,7 +310,7 @@ protected function _registerCatalogProductDeleteEvent(Mage_Index_Model_Event $ev
*/
protected function _registerCatalogProductMassActionEvent(Mage_Index_Model_Event $event)
{
/* @var $actionObject Varien_Object */
/* @var Varien_Object $actionObject */
$actionObject = $event->getDataObject();
$attributes = array(
'status'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* @package Mage_CatalogInventory
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Configurable
extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Configurable
class Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Configurable extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Configurable
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* @package Mage_CatalogInventory
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Default
extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Default
class Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Default extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Default
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* @package Mage_CatalogInventory
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Grouped
extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Grouped
class Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Grouped extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Grouped
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* @package Mage_CatalogInventory
* @author Magento Core Team <core@magentocommerce.com>
*/
interface Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Interface
extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Interface
interface Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Interface extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Interface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* @package Mage_CatalogInventory
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_CatalogInventory_Model_Mysql4_Stock_Item_Collection
extends Mage_CatalogInventory_Model_Resource_Stock_Item_Collection
class Mage_CatalogInventory_Model_Mysql4_Stock_Item_Collection extends Mage_CatalogInventory_Model_Resource_Stock_Item_Collection
{
}
Loading