2012-08-29 9 views
6

प्राप्त करें मैंने सभी प्रकार की चीजों की कोशिश की है और मुझे कहीं भी नहीं मिल रहा है। कृपया कोई मुझे दिखाएगा कि सभी उपलब्ध उत्पाद विशेषता सेटों का नाम और आईडी कैसे प्राप्त करें? एक 'डिफ़ॉल्ट' होगा ...Magento उपलब्ध विशेषता सेट आईडी और बाहरी स्क्रिप्ट से नाम

मैं एक कस्टम उद्धरण प्रणाली का निर्माण कर रहा हूं और विशेषता सेट में खींचने की आवश्यकता है ताकि उपयोगकर्ता पहले उस चयन को लोड कर सकें जो उस सेट को सौंपा गया हो।

आपकी मदद के लिए बहुत धन्यवाद।

$attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection') ->load(); 

दोहराएं:

उत्तर

12

आप विशेषता लोड कर सकते हैं के साथ सेट

foreach ($attributeSetCollection as $id=>$attributeSet) { 
    $entityTypeId = $attributeSet->getEntityTypeId(); 
    $name = $attributeSet->getAttributeSetName(); 
    Mage::log("ATTRIBUTE SET :".$name." - ".$id); 
} 

फिर आप विशेषता निर्धारित करके अपने संग्रह लोड कर सकते हैं।

+0

बिल्कुल सही:

दरअसल आप अपने System.Xml इस तरह में क्षेत्र की आवश्यकता होगी! बहुत धन्यवाद :) –

+1

कोड सभी विशेषता सेट देता है। मैं केवल उन लोगों को चाहता था जो 'Admin> विशेषताएँ> विशेषता समूह प्रबंधित करें' में देखे जाते हैं। संग्रह में जोड़ें: // हम केवल सेट में रूचि रखते हैं जिनका उपयोग उत्पादों के लिए किया जा सकता है, एक फ़िल्टर जोड़ें। > _ PrepareCollection() और // Mage_Adminhtml_Catalog_Product_SetController - - // Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Grid के आधार पर> _ setTypeId() $ ENTITY_TYPE = दाना :: getModel ('सूची/उत्पाद') -> getResource() -> getTypeId(); $ विशेषता SetCollection-> setEntityTypeFilter ($ entity_type); एनबी इस काम के लिए, '-> लोड()' भाग को हटा दें। – Mondane

2

आप पाने के लिए attributeSets जिसमें दिखा रहे हैं व्यवस्थापक की विशेषता निर्धारित अनुभाग का प्रबंधन आप नीचे दिए गए कोडिंग पालन कर सकते हैं कोशिश कर रहे हैं तो के रूप में:

<?php 
     require_once('app/Mage.php'); 
     umask(0); 
     Mage::app();//->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); 
     $entityType = Mage::getModel('catalog/product')->getResource()->getTypeId(); 
     $collection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter($entityType); 
     $allSet = array(); 
     foreach($collection as $coll){ 
     $attributeSet['name'] = $coll->getAttributeSetName(); 
     $attributeSet['id'] = $coll->getAttributeSetId(); 
     $allSet[] = $attributeSet; 
     } 
     echo "<pre>"; 
     print_r($allSet); 
     echo "</pre>"; 
?> 

क्लिक करें here! अधिक संदर्भ के लिए।

0

आप अपने Magento व्यवस्थापक सिस्टम> विन्यास में एक गुण सेट चयनकर्ता प्राप्त करना चाहते हैं इस वर्ग के लिए उपयोगी होगा:

class CompanyName_ModuleName_Model_System_Config_Source_Catalog_Product_Attributeset 
{ 

    protected $_options = array(); 

    public function toOptionArray() 
    { 
     if (!count($this->_options)) { 
      $entityTypeId   = Mage::getResourceModel('catalog/product')->getTypeId(); 
      $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection') 
        ->setEntityTypeFilter($entityTypeId); 

      foreach ($attributeSetCollection as $_attributeSet) { 
       $this->_options[] = array(
        'value' => $_attributeSet->getId(), 
        'label' => $_attributeSet->getAttributeSetName() 
       ); 
      } 
     } 
     return $this->_options; 
    } 

} 

ये सेट विशेषता catalog_product इकाई प्रकार द्वारा सीमित हैं।

<select_attribute_set translate="label"> 
    <label>Default Attribute Set for new importing products</label> 
    <frontend_type>select</frontend_type> 
    <source_model>companyname_modulename/system_config_source_catalog_product_attributeset</source_model> 
    <sort_order>30</sort_order> 
    <show_in_default>1</show_in_default> 
</select_attribute_set>